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):
eval exec "$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 command
if [ "$MAVEN_MAIN_CLASS" = "org.apache.maven.cling.MavenCling" ]; then
eval exec "$cmd" '$MAVEN_ARGS' '"$@"'
else
eval exec "$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.
The
mvnupshell script delegates tomvn --up "$@", and themvnlauncher unconditionally prepends$MAVEN_ARGSto the command line (line 299 inbin/mvn):When
MAVEN_ARGScontains build-specific flags (e.g.-ntp,-T4,-U), these are passed toMavenUpClingwhich does not recognize them.The current workaround in PR #12454 is a retry loop in
CommonsCliUpgradeOptions.CLIManager.parse()that catchesUnrecognizedOptionExceptionand strips unknown options one by one — this is fragile and hides real argument errors from the user.Proposed fix
In the
mvnshell script (bin/mvnandbin/mvn.cmd), skip$MAVEN_ARGSwhen the main class is not the defaultMavenCling. Thehandle_argsfunction already detects--up/--enc/--shellto setMAVEN_MAIN_CLASS; use that to gateMAVEN_ARGSinclusion:Same change needed in
bin/mvn.cmd.Once fixed, the retry loop in
CommonsCliUpgradeOptionscan be removed — replaced with a simplesuper.parse(args)that fails fast on truly unrecognized options.