Fix #12868: Restore --define as long option for -D - #12869
Conversation
The --define long option was the long form of -D in Maven 3.x but was
accidentally omitted during the Maven 4 CLI rewrite (CLIng). This restores
.longOpt("define") on the -D option builder in both the new CLI
(CommonsCliOptions) and the compat layer (CLIManager).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
left a comment
There was a problem hiding this comment.
Clean, minimal regression fix that correctly restores --define as the long option for -D, matching Maven 3.x behavior. The one-line production changes are precise and the new test class adequately covers the fix.
The fix is verified correct by comparing with maven-3.9.x and maven-3.10.x branches, where .longOpt("define") is present on the -D option. The omission clearly happened during the Maven 4 CLI rewrite (CLIng) when the option builder was rewritten and the .longOpt("define") was accidentally dropped.
Test coverage is good: tests cover -Dfoo=bar (short form), --define foo=bar (long form), and multiple --define flags.
Minor observations:
- The compat
CLIManagerchange is untested — the existingCLIManagerDocumentationTestonly generates docs. Since this is a deprecated compat layer and the primary CLI has proper test coverage, this is acceptable.
🔀 Backport Status
master but no backport PR was found for:
maven-4.0.x— has the same omission (confirmed by examining the branch)
The maven-3.9.x and maven-3.10.x branches already have .longOpt("define"), so no backport is needed there.
Consider creating a backport PR or adding a backport-to-maven-4.0.x label.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
The --define long option was the long form of -D in Maven 3.x but was
accidentally omitted during the Maven 4 CLI rewrite (CLIng). This restores
.longOpt("define") on the -D option builder in both the new CLI
(CommonsCliOptions) and the compat layer (CLIManager).
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Closes #12868
Summary
--defineas the long option for-D, which was present in Maven 3.x but accidentally omitted during the Maven 4 CLI rewrite (CLIng).longOpt("define")to the-Doption builder in both the new CLI (CommonsCliOptions) and the compat layer (CLIManager)-Dand--definework correctlyTest plan
CommonsCliOptionsTestverifying-Dfoo=bar,--define foo=bar, and multiple--defineoptionsmvn test -Dtest=CommonsCliOptionsTest)mvn clean install -DskipTests)🤖 Generated with Claude Code