eclipse-m2e / m2e-core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug 543631 - Eclipse - Maven - JPMS (m2e ignores compilerArgs in pom.xml)

LAlves91 opened this issue · comments

Originally reported by Imanuel Rohlfing at bug.eclipse.org. There's also a Stack Overflow discussion on the subject.

Currently im migrating legacy-projects from java 8 to java 11. There are some issues using vm args like add-modules, add-> > > exports and add-opens:

Some base informations:

  • eclipse 2018-12 for Java developers
  • buildin maven (3.5.3)
  • java 11 (open-jdk-hotspot_11.0.1_13-windows-x64)

Within the pom im adding modules and exports:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<version>${compiler.plugin.version}</version>
	<configuration>
		<source>11</source>
		<target>11</target>
		<compilerArgs>
			<arg>--add-modules=java.desktop</arg>
			<arg>--add-exports=java.desktop/com.sun.java.swing.plaf.motif=ALL-UNNAMED</arg>
		</compilerArgs>
	</configuration>
</plugin>

Thats working fine. Using maven to compile the project ends with success.
But eclipse shows problems (the type xxx is not accessable).

To avoid these problems i can modify the project configurtaion:
Java Build Path -> Libraries -> JRE System Library [JavaSE-11] -> Is modular -> Edit

BUT: m2e is controlling the project settings. maven update command removes the changes in the project settings every time.

In the project I work on, we've managed to find a temporary fix by adding the modules we need at the project's configuration (or by adding them in our .classpath file). It stays functional as long as we don't forget to turn off the option 'Update project configuration from pom.xml' when running 'Maven > Update project...'.

This bug has been open for 3 years now. I thought this was going to be fixed in 4.22, (2021-12) but the problem is still there. In fact, it not only impacts compiler JPMS args specified with the compiler plugin, it also impacts JPMS args specified in the surefire plugin.

This bug severely impacts smooth migration from Java 8 to Java 9+.

This bug has been open for 3 years now.
This bug severely impacts smooth migration from Java 8 to Java 9+.

I think lots of project where migrated in the past years so it seem not to impact at least that people that contribute to m2e. Can you try to provide a PR that mitigates the problem?

For me it is working when <arg>--add-exports=java.desktop/com.sun.java.swing.plaf.motif=ALL-UNNAMED</arg> is correctly specified as <arg>--add-exports</arg> and <arg>java.desktop/com.sun.java.swing.plaf.motif=ALL-UNNAMED</arg> .

See also here.

I can confirm that "--add-exports" is working for me, too.
"--add-modules", however, seems to be not working, yet.

commented

I am on Version: 2022-06 (4.24.0), m2e 1.20.1.20220227-1319
and still, the bug is there, every time I update the project from maven, all the maven-compiler-plugin compilerArgs exports (I am on JDK11) are lost.
The only way I can mitigate this is to duplicate the args to the Run/Debug configuration VM args, that sucks.

It seems this issue is not relevant to any current m2e contributor and no one else cared enough to propose a patch.
So if this is crucial to someones business and likes to speed up the development in that area a sponsoring would allow me to assign more time-slots particular issue.

Beside that, please note that m2e 2.x is the current version, so bugifxes of any kind for m2e 1.x are very unlikely.