Repository navigation
MNG-8725: Support max thread configuration - #13229
Conversation
gnodet-bot
left a comment
There was a problem hiding this comment.
The max keyword works correctly in the deprecated compat/ path and the modern impl/ path, and the MavenCli tests are thorough. However, there is a test coverage gap in the production code path that needs to be addressed.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
The test coverage gap flagged in my previous review is now fixed — LookupInvokerTest.java is thorough and correctly exercises all calculateDegreeOfConcurrency paths on the production code path, including max/MAX/Max, error cases, and the boundary message assertion.
One remaining gap: the public API Javadoc is out of sync.
MavenOptions.threads() Javadoc — not updated
api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvn/MavenOptions.java line 164:
// current
@return an {@link Optional} containing the number of threads (or "1C" for one thread per CPU core), or empty if not specified
// should be
@return an {@link Optional} containing the number of threads (e.g. {@code 4} for an integer,
{@code 2C} or {@code 2.5C} for a CPU multiplier, or {@code max} for available processors minus 1,
minimum 1), or empty if not specifiedThis is the interface that embedders read to understand what values threads() can return. The PR correctly updates the two CLI help strings (CLIManager.java and CommonsCliMavenOptions.java) but misses the API-level contract. Since MavenOptions is the SPI boundary, this update belongs in the same PR.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
Both previous findings are now addressed:
- ✅ Test coverage for
LookupInvoker.calculateDegreeOfConcurrency—LookupInvokerTest.javaexercises all paths including case-insensitivemax/MAX/Max, boundary values, all error cases, and verifies the error message mentions'max'. - ✅
MavenOptions.threads()Javadoc — updated to document themaxkeyword, the CPU-1 semantics, and the minimum-1 floor.
Implementation is correct and consistent: LookupInvoker and MavenCli are byte-for-byte identical on the max branch. Single-CPU edge case handled correctly (Math.max(1, 0) = 1).
This review was generated by an AI agent, Hermès on behalf of @gnodet.
- Add 'max' keyword to -T/--threads option: resolves to availableProcessors-1, minimum 1, case-insensitive - Update both LookupInvoker (Maven 4.x production path) and MavenCli (compat/deprecated path) identically - Update CLIManager and CommonsCliMavenOptions option descriptions to document the new keyword - Update MavenOptions Javadoc with full format summary including 'max' - Add LookupInvokerTest covering 'max', 'MAX', 'Max', numeric, multiplier, and all invalid-input cases
2c00d42 to
e3edf2d
Compare
Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.