apache / maven-mvnd

Apache Maven Daemon
https://maven.apache.org/
Apache License 2.0
2.85k stars 205 forks source link

Set `MAVEN_CMD_LINE_ARGS` env #1008

Closed gsmet closed 4 weeks ago

gsmet commented 1 month ago

First, thanks for this amazing project, it makes my Quarkus builds a lot faster.

When using vanilla Maven, MAVEN_CMD_LINE_ARGS is set to whatever the Maven command line is.

This allows you to inspect the Maven command line in extensions (for instance a Develocity extension).

Unfortunately, mvnd doesn't set this environment variable and I couldn't find an easy (and reliable) way to get the command line in a way that wouldn't get cluttered with a lot of non relevant arguments (i.e. I don't want to use ProcessHandle.current().info().commandLine()).

Would it be possible to mimic the Maven behavior (ideally) or expose it in some easily consumable way?

For a use case, see https://github.com/quarkusio/quarkus-project-develocity-extension/blob/fa6fa13df7b56c31d6ba71b2b60017a5d827c8fb/src/main/java/io/quarkus/develocity/project/QuarkusProjectDevelocityConfigurationListener.java#L96 .

Note that I might have missed something obvious but I inspected System.getenv() and System.getProperties() to no avail.

gnodet commented 1 month ago

Hey Guillaume, I'm not completely sure about this one. I suppose it could be added back in the mvnd branch supporting Maven 3.x, but that environment variable has been removed in 4.x (see https://issues.apache.org/jira/browse/MNG-7192). You may want to raise a JIRA issue for 4.x explaining your use case so that a better solution can be found.

gsmet commented 4 weeks ago

Thanks for the answer. Let's close this one. I'll see if there are any other alternatives.