Set maven.multiModuleProjectDirectory as system property#3761
Open
chagong wants to merge 1 commit intoeclipse-jdtls:mainfrom
Open
Set maven.multiModuleProjectDirectory as system property#3761chagong wants to merge 1 commit intoeclipse-jdtls:mainfrom
chagong wants to merge 1 commit intoeclipse-jdtls:mainfrom
Conversation
Contributor
|
Can one of the admins verify this patch? |
The Maven CLI launcher sets maven.multiModuleProjectDirectory as a JVM system property (-D) pointing to the directory containing .mvn/. JDTLS computes this value and injects it as a Maven profile property, but m2e's MavenExecutionContext.populateSystemProperties() reads from System.getProperties(), not from profile properties. This means in POMs remains unresolved during model building, breaking projects like Apache Dubbo and Google Guava that use it in resource directory paths. Set the property via System.setProperty() to mirror the mvn launcher behavior. This is only done when the property isn't already set externally. Fixes eclipse-jdtls#3760 Signed-off-by: Changyong Gong <chagon@microsoft.com>
0a9b603 to
5813cc0
Compare
Contributor
|
add to whitelist |
Contributor
|
@snjeza can you please review? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Projects that reference
${maven.multiModuleProjectDirectory}in their POM fail to import because the property is never interpolated. The Maven CLI launcher (mvn) sets this as a JVM system property via-Dmaven.multiModuleProjectDirectory=..., but JDTLS does not.JDTLS already computes the value correctly in
StandardPreferenceManagerand injects it as a Maven profile property. However, m2e'sMavenExecutionContext.populateSystemProperties()reads fromSystem.getProperties(), not profile properties. So${maven.multiModuleProjectDirectory}remains unresolved during Maven model building.Affected projects
<directory>${maven.multiModuleProjectDirectory}</directory>in<resources>${maven.multiModuleProjectDirectory}in POM expressionsError
Result: project loses Java nature —
The 'dubbo-common' project has no .classpath. Removing Java nature and builder.Fix
Call
System.setProperty(MAVEN_MULTI_MODULE_PROJECT_DIRECTORY, multiModuleProjectDirectory)inStandardPreferenceManagerafter computing the value, only when the property isn't already set externally. This mirrors themvnlauncher behavior.Note: There is also a downstream bug in m2e's
AbstractJavaProjectConfigurator.getFolder()that crashes when a resolved resource directory is an ancestor of the project — fix submitted as eclipse-m2e/m2e-core#2160. Both fixes are needed for full resolution.Fixes #3760