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

One way sync for jpms args from maven compiler args to .classpath file #216

Closed
wants to merge 7 commits into from

Conversation

treilhes
Copy link
Contributor

@treilhes treilhes commented Jun 5, 2021

This commit :

  • get the maven-compiler-plugin compiler arguments if any
  • use regex to parse them and extract jpms arguments (--add-exports,--add-opens,--add-reads,--patch-module)
  • dispatch the arguments in the right container (if the target module is part of JRE then in JreContainer else in M2eContainer)
  • transform them into classpath attribute (add-exports, add-opens, add-reads, patch-module)
  • 1 junit test

Copy link
Contributor

@fbricon fbricon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice contribution! I've only skimmed it from the browser, so mostly bikeshed complaints for now, I'll get into more details later.
There's probably a couple utility methods that already exist that could be used in your test. But I'll look into it.

@@ -173,6 +173,21 @@ public static IClasspathEntry getMavenContainerEntry(IJavaProject javaProject) {
return null;
}

public static IClasspathEntry getJREContainerEntry(IJavaProject javaProject) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to MavenClasspathHelpers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. What about getMavenContainerEntry, isn't it a bit similar ?

assertTrue(m2eAttributes.get(ADD_READS_ATTR).equals(M2E_ADD_READS_VALUE1));
assertTrue(m2eAttributes.get(PATCH_MODULE_ATTR).equals(M2E_PATCH_MODULE_VALUE1));

String argsSet2Content = contents.replace(REPLACED_POM_STRING, argsSet2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better to cover compilerArgument works as intended on the second test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not handle compilerArgument anymore in the getCompilerAgument method. As the maven-compiler-plugin doc states, all the jpms arguments are in fact two arguments so no complete jpms argument can be provided using compilerArgument.

And i think it is not worth supporting the following cases:

<compilerArgument>--add-exports</compilerArgument>
<compilerArgs>
   <arg>somemodule/somepackage=someothermodule</arg>
</compilerArgs>

<compilerArgs>
   <arg>--add-exports</arg>
</compilerArgs>
<compilerArgument>somemodule/somepackage=someothermodule</compilerArgument>

Do you agree ?

Copy link
Contributor

@fbricon fbricon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once jpms flags are removed from pom.xml, they should be removed from the eclipse classpath as well

Also:
sources updated according review comments
@treilhes treilhes requested a review from fbricon June 7, 2021 10:37
@treilhes
Copy link
Contributor Author

treilhes commented Jun 7, 2021

Hi @fbricon,

I've checked the continuous integration logs and i'm wondering how my code could be the cause of the failures.
Do you think my code can be responsible for this kind of failure?

testDownloadSources_006_nonMavenProject(org.eclipse.m2e.tests.BuildPathManagerTest)  Time elapsed: 2.649 s  <<< ERROR!
org.eclipse.core.runtime.CoreException: Reindexing error
	at org.eclipse.m2e.tests.BuildPathManagerTest.testDownloadSources_006_nonMavenProject(BuildPathManagerTest.java:656)
Caused by: java.nio.channels.OverlappingFileLockException
	at org.eclipse.m2e.tests.BuildPathManagerTest.testDownloadSources_006_nonMavenProject(BuildPathManagerTest.java:656)

The last build failure seems even more unrelated to my code :

Transfer failed for https://repo.eclipse.org/content/repositories/cbi-releases/org/apache/maven/doxia/doxia-module-apt/1.0/doxia-module-apt-1.0.pom 503 Service Unavailable -> [Help 2]

Rgds,
Live long and prosper

@fbricon
Copy link
Contributor

fbricon commented Jun 7, 2021

testDownloadSources_006_nonMavenProject has been failing for quite some time, it's unrelated. That test (or the regression it seems to indicate) needs to be fixed, but that's another battle.

Eclipse's nexus instance might be unstable and cause the other issue.

@treilhes
Copy link
Contributor Author

treilhes commented Jun 7, 2021

As a side note, it will solve:

#129 Bug 543631 - Eclipse - Maven - JPMS (m2e ignores compilerArgs in pom.xml)
#136 Bug 535650 - Update Project removes add-export declarations in Java 9 projects

treilhes added a commit to treilhes/scenebuilder that referenced this pull request Jun 9, 2021
@treilhes
Copy link
Contributor Author

Hi @fbricon,
What do you think about my comments on compilerArgument and testCompilerArguments support ?

@fbricon
Copy link
Contributor

fbricon commented Jun 18, 2021

Hi @fbricon,
What do you think about my comments on compilerArgument and testCompilerArguments support ?

Sorry for the late reply. I need to take a closer look. I'll do a deeper review next week.

@YaYsimulator
Copy link

YaYsimulator commented Aug 19, 2021

Hi @fbricon
What is the status of this pull request? The project I'm currently working on for my colleagues would benefit greatly from this fix. :)

@leerho
Copy link

leerho commented Aug 19, 2021

I am also very interested in this fix. Is there any hope of getting this PR accepted?

@gayanper
Copy link
Contributor

gayanper commented Sep 4, 2021

I did test this change by merging in to latest master branch and doing a local build. I have been running it for one week now with my daily driver eclipse setup. I have not found any issues related to this change.

So @treilhes can we resolve the conflicts and make it ready to merge and @fbricon can we merge this so that we can have this support in the next release for Eclipse 4.22 ?

@treilhes
Copy link
Contributor Author

treilhes commented Sep 4, 2021

Hello @gayanper,
I did try to fix it but the issue is related to some maven index lock and is completely unrelated to this pull request.
All the pull requests seem to suffer from this test failure and solving it requires someone knowing the inner working of m2e not a casual user like me.

@fbricon, are you still around? I hope the covid did not get you and you are well .....

Can someone give us some feedback ?

@mickaelistria
Copy link
Contributor

Rebased and merged as f23d3f8 ; thanks!
Would you please add a note about it in the RELEASE_NOTES document?

@mickaelistria mickaelistria added this to the 1.18.2 milestone Sep 5, 2021
treilhes added a commit to treilhes/m2e-core that referenced this pull request Sep 5, 2021
treilhes added a commit to treilhes/m2e-core that referenced this pull request Sep 5, 2021
@treilhes
Copy link
Contributor Author

treilhes commented Sep 5, 2021

Hello @mickaelistria,
Don't know if it was the right way to do it but you can find the updated release note for this pr in #322

mickaelistria pushed a commit that referenced this pull request Sep 5, 2021
@leerho
Copy link

leerho commented Jan 8, 2022

I thought this was going to be fixed in 4.22, 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+.

@mickaelistria
Copy link
Contributor

@leerho: can you please report a new issue with details to easily reproduce against latest m2e release please?

@leerho
Copy link

leerho commented Jan 13, 2022

Will do. I figured it was already reported. It will take me some time to prepare the "easily reproduce" part :)

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

Successfully merging this pull request may close these issues.

6 participants