You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mvnup should not inherit MAVEN_ARGS environment variable #12464
The mvnup shell script delegates to mvn --up "$@", and the mvn launcher unconditionally prepends $MAVEN_ARGS to the command line (line 299 in bin/mvn):
evalexec"$cmd"'$MAVEN_ARGS''"$@"'
When MAVEN_ARGS contains build-specific flags (e.g. -ntp, -T4, -U), these are passed to MavenUpCling which does not recognize them.
The current workaround in PR #12454 is a retry loop in CommonsCliUpgradeOptions.CLIManager.parse() that catches UnrecognizedOptionException and strips unknown options one by one — this is fragile and hides real argument errors from the user.
Proposed fix
In the mvn shell script (bin/mvn and bin/mvn.cmd), skip $MAVEN_ARGS when the main class is not the default MavenCling. The handle_args function already detects --up/--enc/--shell to set MAVEN_MAIN_CLASS; use that to gate MAVEN_ARGS inclusion:
# Only pass MAVEN_ARGS for the default Maven build commandif [ "$MAVEN_MAIN_CLASS"="org.apache.maven.cling.MavenCling" ];thenevalexec"$cmd"'$MAVEN_ARGS''"$@"'elseevalexec"$cmd"'"$@"'fi
Same change needed in bin/mvn.cmd.
Once fixed, the retry loop in CommonsCliUpgradeOptions can be removed — replaced with a simple super.parse(args) that fails fast on truly unrecognized options.
IMHO, ideally no other command than mvn should behave as documented. Currently, all commands pretty much do the same, even if it makes no sense for them.
Activity
cstamas commentedon Jul 10, 2026
IMHO, ideally no other command than
mvnshould behave as documented. Currently, all commands pretty much do the same, even if it makes no sense for them.Revert unrecognized option retry loop in mvnup (see apache#12464)
Fix #12464: Skip MAVEN_ARGS for non-default main classes (--up, --enc…
Fix #12464: Skip MAVEN_ARGS for non-default main classes (--up, --enc…
Fix #12430: mvnup upgrade strategies and compatibility improvements (#…
Backport #12454: mvnup upgrade strategies and compatibility improveme…