I have a Java 11 project which defines a module-info.java and is compliant with JPMS - except that it requires unnamed modules from other developers that did not yet care about JPMS.
When I put the Maven dependencies in the module path, that is, in the .classpath
of Eclipse I have
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
then everything works just fine. However, when I select Maven -> Update Project in Eclipse, then Eclipse will remove the line
<attribute name="module" value="true"/>
After that, the project shows an error in Eclipse (" The type xxx cannot be resolved. It is indirectly referenced from required.class file. ").
How can I tell Maven to keep the <attribute name="module" value="true"/>
upon "Maven -> Update Project...".
(Eclipse version is 2020-03)
I use this in my pom.xml
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.version}</release>
<fork>true</fork>
<showWarnings>true</showWarnings>
<debug>true</debug>
<debuglevel>source,lines</debuglevel>
<verbose>true</verbose>
<modulePath>
<dependency>org.apache.logging.log4j:log4j-api</dependency>
<dependency>org.apache.logging.log4j.core:log4j-core</dependency>
... etc ...
</modulePath>
</configuration>
</plugin>
But, unfortunately, some modulePath > dependency
work fine, others do not.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.