Fix #12464: Skip MAVEN_ARGS for non-default main classes (--up, --enc, --shell)#12465
Open
gnodet wants to merge 1 commit into
Open
Fix #12464: Skip MAVEN_ARGS for non-default main classes (--up, --enc, --shell)#12465gnodet wants to merge 1 commit into
gnodet wants to merge 1 commit into
Conversation
… --enc, --shell) When MAVEN_MAIN_CLASS is not the default MavenCling (i.e., when using --up, --enc, or --shell), skip prepending $MAVEN_ARGS to the command line. MAVEN_ARGS may contain build-specific flags like -ntp, -T4, -U that are not recognized by MavenUpCling, MavenEncCling, or MavenShellCling. The handle_args function already sets MAVEN_MAIN_CLASS for these sub-commands — use that to gate MAVEN_ARGS inclusion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
commented
Jul 10, 2026
gnodet
left a comment
Contributor
Author
There was a problem hiding this comment.
Review — Skip MAVEN_ARGS for Non-Default Main Classes
Clean, well-scoped fix that gates $MAVEN_ARGS on the main class being the default MavenCling. Both Unix and Windows scripts are updated with platform-idiomatic approaches.
Analysis
- Unix (
bin/mvn): Conditionalif/elsearound theeval exec— debug output is also correctly gated so it reflects what's actually executed. - Windows (
bin/mvn.cmd): ClearsMAVEN_ARGSbefore the exec line — scoped inside@setlocal/@endlocalso it doesn't leak to the caller. - Edge case: If a user intentionally puts args in
MAVEN_ARGSfor sub-tools, those will be silently dropped. This is correct —MAVEN_ARGSis documented as Maven-specific, and sub-tools have their own option sets. - Complements #12454: With the retry loop reverted, this shell-level gate is the clean solution — sub-tools will properly fail fast on truly unrecognized options.
No issues found. LGTM (own PR, can't APPROVE). ✅
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
gnodet
added a commit
to gnodet/maven
that referenced
this pull request
Jul 10, 2026
New PR apache#12465 (skip MAVEN_ARGS for sub-tools). COMMENT, own PR. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cstamas
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bin/mvn, gate$MAVEN_ARGSinclusion onMAVEN_MAIN_CLASSequaling the defaultMavenCling. When--up,--enc, or--shellis used, thehandle_argsfunction setsMAVEN_MAIN_CLASSto a different class — skipMAVEN_ARGSin that case to avoid passing unrecognized build-specific flags (e.g.-ntp,-T4,-U) to sub-commands.bin/mvn.cmdby clearingMAVEN_ARGSwhen the main class is notMavenCling(safe because the script runs inside@setlocal).MAVEN_DEBUG_SCRIPT) is also updated to reflect the conditional behavior.Closes #12464
Test plan
mvn verify -pl apache-maven)MAVEN_ARGS="-ntp -T4" mvn --up check— should no longer fail with unrecognized option errorsMAVEN_ARGS="-ntp -T4" mvn clean install— should still pass MAVEN_ARGS as beforeMAVEN_ARGS="-ntp" mvn --enc— should not fail on-ntpMAVEN_DEBUG_SCRIPT=1 mvn --up checkdoes not print MAVEN_ARGS in debug output🤖 Generated with Claude Code