Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The module declaration in version 2.11.0 is not visible #2679

Closed
eitan-rosenberg opened this issue May 22, 2024 · 11 comments
Closed

The module declaration in version 2.11.0 is not visible #2679

eitan-rosenberg opened this issue May 22, 2024 · 11 comments

Comments

@eitan-rosenberg
Copy link

eitan-rosenberg commented May 22, 2024

The module declaration in version 2.11.0 is not visible, in contrast to version 2.10.1

Cannot use "requires com.google.gson;" in existing code like I used to.

Please help,

@Marcono1234
Copy link
Collaborator

Marcono1234 commented May 22, 2024

The module declaration is still under META-INF/versions/9/module-info.class inside the JAR, so nothing has changed regarding this between version 2.10.1 and 2.11.0.

Is only your IDE showing this error, or do you get this error also when you run the build tool (probably Maven or Gradle) from command line?

If this also occurs with Maven or Gradle, could you please try to create a small self-contained demo repository which showcases this issue? Please mention:

  • which exact build command you using
  • JDK version
  • Maven / Gradle version
  • operating system

@eitan-rosenberg
Copy link
Author

I am aware that you are using multi-release jar and I noticed META-INF/versions/9/module-info.class.(this is also the case in 2.10.1)
My environment:
Eclipse 2024-03 (4.31).
M2E Maven Integration for Eclipse Core 2.6.0.20240220-1109
Java openjdk-22.0.1_windows-x64_bin.zip
Maven 3.9.6.

I created a small Maven project. (included)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

	<modelVersion>4.0.0</modelVersion>

	<groupId>ModuleTest</groupId>
	<artifactId>ModuleTest</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.compiler.source>22</maven.compiler.source>
		<maven.compiler.target>22</maven.compiler.target>
	</properties>

	<dependencies>

		<dependency>
			<groupId>com.google.code.gson</groupId>
			<artifactId>gson</artifactId>
			<!-- <version>2.11.0</version> -->
			<version>2.10.1</version>
		</dependency>

	</dependencies>

</project>

When using 2.10.1 every thing is ok.

2024-05-23_08-51-31

When using 2.11.0 it fails.

2024-05-23_08-59-56

ModuleTest.zip

Thanks in advance.

@eitan-rosenberg
Copy link
Author

Update...

I checked both jars: the jar compression is not the same:

2024-05-23_15-35-17
2024-05-23_15-33-50

Repacking 2.11.0 make the jar usable.

@Marcono1234
Copy link
Collaborator

But does this error only occur within Eclipse, or also when you run mvn clean test?

If I use the ModuleTest.zip you have attached, change the Gson dependency version to 2.11.0, and then run mvn clean test (with Docker image maven:3.9.6-eclipse-temurin-22-alpine), then it compiles without problems for me.

I think we are using standard Maven plugins for JAR creation. Since last Gson version we upgraded the maven-jar-plugin and moditect-maven-plugin, and made the build reproducible (#2543).

Maybe this should rather be reported as bug for Eclipse.

Just to be sure, did you run "Maven" > "Update Project..." in Eclipse after you changed the dependency? I think it should have done that automatically though.

@Marcono1234
Copy link
Collaborator

And could you please check Eclipse's "Error Log" as well ("Window" > "Show View" > "Other..." > "General" > "Error Log") if it contains any related errors?

@eitan-rosenberg
Copy link
Author

And could you please check Eclipse's "Error Log" as well ("Window" > "Show View" > "Other..." > "General" > "Error Log") if it contains any related errors?
Nothing there.
I even change the JDK:
2024-05-24_05-45-16

@eitan-rosenberg
Copy link
Author

eitan-rosenberg commented May 24, 2024

I can live with :

module moduleTest {

	exports myClasses;

	exports main;

//	requires com.google.gson;

	requires gson;

}

Have you considered using "Automatic-Module-Name" ?
Even org.apache.commons.lang3 use it.

@eitan-rosenberg
Copy link
Author

"But does this error only occur within Eclipse, or also when you run mvn clean test?"

Running "mvn clean test" from the command line works !!!!

I will report to the people in https://github.com/eclipse-m2e/m2e-core

@eitan-rosenberg
Copy link
Author

Thanks

@Marcono1234
Copy link
Collaborator

Marcono1234 commented May 24, 2024

When you create the https://github.com/eclipse-m2e/m2e-core issue, can you please add a link there to this Gson issue here? It might help the m2e maintainers, and it will help anyone else who sees this Gson issue here to find the corresponding m2e issue.

Also, have you tried right-clicking the project in Eclipse and selecting "Maven" > "Update Project...", which I suggested above? (just to be sure)

@eitan-rosenberg
Copy link
Author

Also, have you tried right-clicking the project in Eclipse and selecting "Maven" > "Update Project...", which I suggested above? (just to be sure)
I do that every time I open a project (alt+f5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants