gnodet opened a new issue, #12464:
URL: https://github.com/apache/maven/issues/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`):
   
   ```bash
   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:
   
   ```bash
   # 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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to