Skip to content

Commit 0a9b603

Browse files
committed
Set maven.multiModuleProjectDirectory as system property
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 #3760 Signed-off-by: Changyong Gong <chagon@microsoft.com>
1 parent 7be965c commit 0a9b603

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/StandardPreferenceManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ public void update(Preferences preferences) {
143143
}
144144
}
145145
}
146+
// Set as JVM system property so m2e's MavenExecutionContext.populateSystemProperties()
147+
// picks it up via System.getProperties(). Profile properties alone are not reliably
148+
// propagated to the Maven model interpolator during m2e's import flow, causing
149+
// ${maven.multiModuleProjectDirectory} in POMs to remain unresolved.
150+
if (multiModuleProjectDirectory != null && systemMmpd == null) {
151+
System.setProperty(MAVEN_MULTI_MODULE_PROJECT_DIRECTORY, multiModuleProjectDirectory);
152+
}
146153
updateMavenProjects = updateMavenProjects || !Objects.equals(multiModuleProjectDirectory, oldMultiModuleProjectDirectory) || (oldDisableTest != preferences.isMavenDisableTestClasspathFlag());
147154
mavenSettings.getProfiles().removeIf(p -> JAVALS_PROFILE.equals(p.getId()));
148155
if (preferences.isMavenDisableTestClasspathFlag() || multiModuleProjectDirectory != null) {

0 commit comments

Comments
 (0)