gnodet opened a new issue, #12431: URL: https://github.com/apache/maven/issues/12431
## Summary `mvnup` (`mvn --up`) reads `.mvn/maven.config` and passes its contents through `CommonsCliUpgradeOptions`, which only recognizes mvnup-specific options (`--model`, `--plugins`, `--infer`, `--all`, `--directory`, `--model-version`) plus a small set of base options from `CommonsCliOptions` (`-B`, `-q`, `-e`, etc.). When `.mvn/maven.config` contains Maven build options like `-ntp` (no transfer progress), `-U` (update snapshots), `-T` (threads), or `-Dproperty=value`, the parser throws `ParseException: Unrecognized option` and mvnup aborts **without applying any fixes**. This silently defeats all of mvnup's existing compatibility rules — including the duplicate dependency removal and invalid `combine.self` attribute fixes — on any project that uses `.mvn/maven.config` with build-specific options. ## Impact (from Maven 4 compatibility testing on ~966 Apache projects) At least 2 projects confirmed affected in the current test run: - **commons-jci** — `.mvn/maven.config` contains `-ntp`, mvnup crashes, duplicate dependency `groovy-eclipse-compiler` is not fixed → Maven 4 build fails - **logging-log4j-samples** — `.mvn/maven.config` contains `-ntp`, mvnup crashes, invalid `combine.self="append"` is not fixed → Maven 4 build fails Both projects would pass with the current mvnup rules if mvnup didn't crash before reaching them. The existing `CompatibilityFixStrategy` already handles: - Duplicate dependencies (`fixDuplicateDependencies`) - Invalid `combine.self` values (`fixInvalidCombineSelfAttributes`) ## Error output ``` [ERROR] Error executing Maven Upgrade Tool. [ERROR] Error parsing program arguments [ERROR] Caused by: Failed to parse command line options: Unrecognized option: -ntp [ERROR] Caused by: Unrecognized option: -ntp ``` ## Root cause The launcher script `apache-maven/src/assembly/maven/bin/mvnup` delegates to `mvn --up "$@"`. The `mvn` launcher reads `.mvn/maven.config` and appends its contents to the argument list. These combined args are then parsed by `CommonsCliUpgradeOptions.parse()` → `CLIManager.parse()`, which does strict parsing and rejects any option it doesn't recognize. ## Proposed fix In `CommonsCliUpgradeOptions.CLIManager`, override `parse()` to ignore unrecognized options from `.mvn/maven.config`. The simplest approach: use Commons CLI's `DefaultParser.parse(options, args, true)` (with `stopAtNonOption`) or `parsePartial()`, since mvnup does not need build options like `-ntp`, `-U`, or `-T`. Alternatively, `CommonsCliUpgradeOptions.CLIManager.prepareOptions()` could register all standard Maven CLI options as recognized-but-ignored. ## Test plan - Add test with `-ntp` in args → mvnup should succeed (ignore the flag) - Add test with `-U -T4 -ntp` in args → mvnup should succeed - Add test with `-Dproperty=value` in args → should not crash - Verify existing mvnup options still work correctly - Verify that a project with `.mvn/maven.config` containing `-ntp` and duplicate dependencies gets the duplicates removed -- 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]
