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

maven.multiModuleProjectDirectory is missing in DefaultSettingsBuildingRequest.getSystemProperties() #1031

Closed
gzm55 opened this issue Jun 18, 2024 · 6 comments

Comments

@gzm55
Copy link
Contributor

gzm55 commented Jun 18, 2024

An EventSpy watching SettingsBuildingResult event, cannot get the multiModuleProjectDirectory from system properties.

@cstamas
Copy link
Member

cstamas commented Jun 18, 2024

See related issues and discussions: https://issues.apache.org/jira/browse/MNG-6589

TL;DR: the mentioned property is NOT for public consumption. Moreover, as mvnd 1.0.0 (which version is affected?) is Maven 3.9.8 based, the issue https://issues.apache.org/jira/browse/MNG-7038 does NOT applies as it is Maven4.

@gzm55
Copy link
Contributor Author

gzm55 commented Jun 18, 2024

See related issues and discussions: https://issues.apache.org/jira/browse/MNG-6589

TL;DR: the mentioned property is NOT for public consumption. Moreover, as mvnd 1.0.0 (which version is affected?) is Maven 3.9.8 based, the issue https://issues.apache.org/jira/browse/MNG-7038 does NOT applies as it is Maven4.

only affect mvnd 1.0.0.

Now mvnd 1.x is based on maven-3. How can we get or calculate the value of maven.multiModuleProjectDirectory for both mvnd 1.x and maven 3.x?

@cstamas
Copy link
Member

cstamas commented Jun 18, 2024

You could pass it like this: https://github.com/cstamas/rrf-demo/blob/master/.mvn/maven.config#L2

Explanation: the used property is not a public property, should not be used (is an implementation detail). The new thing in Maven 3.9.x was ${session.rootDirectory} but alas, it is interpolated ONLY IN SETTINGS. Hence, if you just add foo=${session.rootDirectory} you will get the value as $foo among properties as well.

Maven4 makes this new property accessible in settings (like Maven 3.9.x) but also as properties (unlike Maven 3.9).

@gzm55
Copy link
Contributor Author

gzm55 commented Jun 18, 2024

You could pass it like this: https://github.com/cstamas/rrf-demo/blob/master/.mvn/maven.config#L2

Explanation: the used property is not a public property, should not be used (is an implementation detail). The new thing in Maven 3.9.x was ${session.rootDirectory} but alas, it is interpolated ONLY IN SETTINGS. Hence, if you just add foo=${session.rootDirectory} you will get the value as $foo among properties as well.

Maven4 makes this new property accessible in settings (like Maven 3.9.x) but also as properties (unlike Maven 3.9).

thanks!

Tested on 3.9.8, rootDriectory depends on topDirectory. but session.topDirectory seems always be resolved to PWD when invoked with -f /path/to/pom.xml

@korthout
Copy link

korthout commented Jun 19, 2024

I also run into the issue that maven.multiModuleProjectDirectory is no longer available.

I don't understand how to apply this proposed solution. Creating a .mvn/maven.config file with this -Daether.remoteRepositoryFilter.prefixes.basedir=${session.rootDirectory}/.mvn/rrf/ line does not add maven.multiModuleProjectDirectory back. Perhaps I'm missing something.

I was able to work around it by passing it directly:

mvnd package -Dmaven.multiModuleProjectDirectory=$(pwd)

This is not a nice experience though. Especially, since I generally work in a subfolder somwhere (mvnd package -Dmaven.multiModuleProjectDirectory=$(pwd)/../). Any other ideas how to resolve this?

@gzm55
Copy link
Contributor Author

gzm55 commented Jun 19, 2024

I also run into the issue that maven.multiModuleProjectDirectory is no longer available.

I don't understand how to apply this proposed solution. Creating a .mvn/maven.config file with this -Daether.remoteRepositoryFilter.prefixes.basedir=${session.rootDirectory}/.mvn/rrf/ line does not add maven.multiModuleProjectDirectory back. Perhaps I'm missing something.

I was able to work around it by passing it directly:

mvnd package -Dmaven.multiModuleProjectDirectory=$(pwd)

This is not a nice experience though. Especially, since I generally work in a subfolder somwhere (mvnd package -Dmaven.multiModuleProjectDirectory=$(pwd)/../). Any other ideas how to resolve this?

@korthout from 3.9.2, when call with mvn -f /path/X/pom.xml maven replaces ${session.topDirectory} and ${session.rootDirectory} in command line flags (including from .mvn/maven.config with /path/X and the value of ${maven.multiModuleProjectDirectory}. So we should put -Dmaven.multiModuleProjectDirectory=${session.rootDirectory} to pull back the old property.

But now maven 3.9.8 included by mvnd 1.0.0 has a bug (apache/maven#1589) of not correctly dealing with -f flag.

gsmet added a commit to gsmet/quarkus that referenced this issue Jul 2, 2024
mvnd 1.0.1 is not compatible with our build due to:
apache/maven-mvnd#1031
gnodet added a commit to gnodet/mvnd that referenced this issue Jul 16, 2024
gnodet added a commit to gnodet/mvnd that referenced this issue Jul 16, 2024
# Conflicts:
#	daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
#	integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfNativeIT.java
@gnodet gnodet closed this as completed in 9644e46 Jul 16, 2024
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

No branches or pull requests

3 participants