Community
Participate
Working Groups
In my run configurations Maven Dependencies are under Classpath Entries on the Dependencies tab and I cant see any way to move them to Modulepath Entries. This causes an error when I try to run my project: Error occurred during initialization of boot layer java.lang.module.FindException: Module org.apache.logging.log4j not found, required by server If I take the command line it gives me from the "Show Command Line" button and edit it to move all of the classpath arguments to the modulepath (and remove the javaw.exe part) and put that in the VM arguments section and remove all dependencies from the Dependencies tab then it runs without an error.
(you may have to right-click on the project and choose "Maven > Update Project"). The Maven Dependencies container is shown on the classpath, but its contents are actually put on the module path by m2e, if they are mentioned in the module-info.java. Other dependencies are put on the class path. Note that test-only dependencies (like junit), which can not be referenced in the module-info.java, are this way kept on the class path, but test code is automatically configured to read the unnamed module, so this should work.
(In reply to Till Brychcy from comment #1) > (you may have to right-click on the project and choose "Maven > Update > Project"). I tried "Maven > Update Project" and now the line "requires org.apache.logging.log4j;" in my module-info.java shows an error "org.apache.logging.log4j cannot be resolved to a module". Also Maven Dependencies in my build path is now under the Classpath section, I think it was under Modulepath before. There are also errors where I try to import and use log4j.
As I wrote, the location of the maven dependencies container doesn't matter, the invidual entries contained in it should have the "is modular" attribute set if they are in the module-info.java But if I remember correctly, org.apache.logging.log4j is a multi-release jar file (and has the module-info.class in the META-INF/...) folder, there may still be an issue with this
Yes, log4j's module-info.class is in META_INF/versions/9, and log4j-api-2.11.1.jar under Maven Dependencies in the build path has a field "is not modular - non modifiable".
Eclipse shows log4j's module-info.class as being next to the META_INF folder though, not inside it as it actually is in the jar.
(In reply to Alex Foster from comment #5) > Eclipse shows log4j's module-info.class as being next to the META_INF folder > though, not inside it as it actually is in the jar. This ist just Eclipse's view which shows that it actually handles this correctly. But m2e needs to set the module attribute, which it doesn't.
I can reproduce the problem with this pom.xml: <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>test</groupId> <artifactId>test</artifactId> <version>0.0.1-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> <configuration> <source>9</source> <target>9</target> <showWarnings>true</showWarnings> <showDeprecation>true</showDeprecation> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.11.1</version> </dependency> </dependencies> </project> and this src/main/java/module-info.java: module test { requires org.apache.logging.log4j; } (actually completion of the module name works)
org.eclipse.m2e.jdt.internal.InternalModuleSupport.getModuleName(File) doesn't support multi-release jar files.
New Gerrit change created: https://git.eclipse.org/r/131170
Thank you, this is working now, but I seem to have another similar problem. My project depends on another project (Common) which is not a maven project. Common depends on a user library (LWJGL). LWJGL has several multi release jar files with the module-info.class under META_INF/versions/9, and Common's build path shows these jars with the field "is not modular - not modifiable". The user library has a field "is modular" though, and it is under Modulepath. The first project builds correctly now (and so does Common), but running it fails with: Error occurred during initialization of boot layer java.lang.module.FindException: Module org.lwjgl not found, required by common Unless I edit the run configuration VM arguments to put all of the classpath arguments on the modulepath and remove all dependencies, in which case it runs without errors. Should I open a new bug?
(In reply to Alex Foster from comment #10) > Should I open a new bug? Yes (I haven't really understood, so it would be important to have an example project)
(In reply to Till Brychcy from comment #11) > (In reply to Alex Foster from comment #10) > > Should I open a new bug? > > Yes (I haven't really understood, so it would be important to have an > example project) Created here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=540305
org.eclipse.m2e.jdt.internal.InternalModuleSupport.getRequiredModules(File) needs the same change.
Created attachment 276336 [details] maven projects for testing
I've attached some projects for manual testing (I haven't found any java-9 related infrastructure in the m2e-test project on github). baseA and baseB are two simple modular projects consisting just of module-info.class multi is a project that creates a multi-release jar just with module-info, where version 9 requires baseA and version 10 requires baseB To test, do "mvn install" for baseA, baseB and multi using the command line (and java >=10) then import test as maven project into eclipse. verify that baseA is shown as modular in the "Maven Dependencies Container" and baseB is not now edit pom.xml (of test) and change the target to 10 right click on "test"-project and choose "maven > update project" verify that baseA is not shown as modular in the "Maven Dependencies Container" and baseB is.
Created attachment 276337 [details] maven projects for testing with module names that differ from project names
I've attached some projects for manual testing (I haven't found any java-9 related infrastructure in the m2e-core-tests project on github). baseA and baseB are two simple modular projects consisting just of module-info.class where baseA declares mod_baseA and baseB declares mod_baseB. multi is a project that creates a multi-release jar just with module-info, where the module name in version 9 is multiA and requires mod_baseA; and in version 10 the module name is multiB and it requires mod_baseB To test, do "mvn install" for baseA, baseB and multi using the command line (and java >=10). Do not import these into eclipse (at least not multi, or disable workspace resolution for the projects that need it) Then import test9 and test10 as maven project into eclipse. Both projects should compile without errors (but note: module-info in test9 requires multiA and the one in test10 requireds multiB) Verify that baseA is shown as modular in the "Maven Dependencies" Container of test9 and baseB is not modular Verify that baseA is shown as not modular in the "Maven Dependencies" Container of test10 and baseB is shown as modular
Gerrit change https://git.eclipse.org/r/131170 was merged to [master]. Commit: http://git.eclipse.org/c/m2e/m2e-core.git/commit/?id=090aeb23dae6ab331d8fffb158b563bc88c19d51
Thanks for the patch Till, it works as advertised. Merged as http://git.eclipse.org/c/m2e/m2e-core.git/commit/?id=090aeb23dae6ab331d8fffb158b563bc88c19d51 As for missing Java 9+ tests, we definitely need to set it up. I know how to do it (register fake rtstubs.jars as test JREs, like in JDT/JDT.LS tests), but don't have the bandwidth to do it right now
Moved to https://github.com/eclipse-m2e/m2e-core/issues/