MNG-7884: Add --print-build-order option to print reactor build order without building#12486
Conversation
gnodet
left a comment
There was a problem hiding this comment.
Review: MNG-7884 — Add --print-build-order option
Verdict: Incomplete — needs more work before merge
The PR adds CLI option parsing for --print-build-order / -pbo across the three expected files in the options layer (MavenOptions.java, CommonsCliMavenOptions.java, LayeredMavenOptions.java). The option name is clear, the short code -pbo doesn't conflict with existing options, and it follows Maven CLI conventions.
However, the feature is not yet functional — the PR description itself notes several pieces are "(In progress)":
Findings
1. Feature not wired up (high)
The option is parsed but never consumed. There is no code in MavenInvoker, MavenExecutionRequest, or DefaultMaven.doExecute() that reads printBuildOrder() and acts on it. Running mvn --print-build-order would accept the flag but silently do nothing.
→ The PR should either be marked as draft until wiring is complete, or include the remaining implementation.
2. Missing @Nonnull annotation (medium)
Every other Optional<...> method in MavenOptions.java has @Nonnull on the return type. The new printBuildOrder() omits it.
3. No tests (medium)
No unit or integration tests are included. At minimum, a parsing test for CommonsCliMavenOptions confirming -pbo / --print-build-order is correctly parsed would be expected.
4. Javadoc @return style (low)
The @return tag deviates from the established pattern. Other methods use:
an {@link Optional} containing true if ..., false if ..., or empty if not specified
The new method uses a different format.
Positive notes
- The JIRA issue MNG-7884 is valid and the feature is genuinely wanted
- Option naming is good and conflict-free
- Placement in the options interface is reasonable
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
This comment was marked as off-topic.
This comment was marked as off-topic.
gnodet
left a comment
There was a problem hiding this comment.
Re-review after new commits
Thanks for addressing the feedback! Two items fixed:
- ✅ @nonnull annotation — added, now consistent with all other
Optional<...>methods - ✅ Javadoc @return style — now matches the established pattern
Still outstanding:
- Feature not wired up (high) — the option is parsed but still never consumed anywhere in the execution path.
mvn --print-build-orderwould accept the flag but silently do nothing. - No tests (medium) — at minimum a parsing test for
CommonsCliMavenOptionswould be expected.
Consider marking as draft until the wiring (into MavenExecutionRequest / DefaultMaven.doExecute()) is complete, or adding the remaining implementation in follow-up commits.
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
What
Adds a new CLI flag
--print-build-order(short form-pbo) that prints the reactor'stopologically-sorted build order and exits, without executing the build lifecycle.
Why
Closes #8733 (MNG-7884). This is useful for analyzing a multi-module build's execution
order without committing to a full build — e.g. in CI diagnostics, scripting, or simply
understanding module interdependencies in large reactors.
How
printBuildOrder()to theMavenOptionsAPI interface (api/maven-api-cli).CommonsCliMavenOptions(newPRINT_BUILD_ORDERconstantand
Optionregistration in the nestedCLIManager).LayeredMavenOptions.MavenExecutionRequestviaMavenInvoker.populateRequest(...).isPrintBuildOrder()/setPrintBuildOrder(boolean)toMavenExecutionRequest/DefaultMavenExecutionRequest.DefaultMaven.doExecute(...), after the authoritativebuildGraph(session)call succeeds, checking the flag and — if set — printing the sorted project list and
returning a clean success result before
lifecycleStarter.execute(session)runs.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.