GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — #8733: Add --print-build-order option to print reactor build order without building by AbdelHamdyGhanem · Pull Request #12486 · apache/maven

Conversation

@AbdelHamdyGhanem

@AbdelHamdyGhanem AbdelHamdyGhanem commented Jul 13, 2026 •
edited by gnodet
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

What

Adds a new CLI flag --print-build-order (short form -pbo) that prints the reactor's
topologically-sorted build order and exits, without executing the build lifecycle.

Why

Closes #8733 (#8733). 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

  • Added printBuildOrder() to the MavenOptions API interface (api/maven-api-cli).
  • Implemented option parsing in CommonsCliMavenOptions (new PRINT_BUILD_ORDER constant
    and Option registration in the nested CLIManager).
  • Added the corresponding merge-layer override in LayeredMavenOptions.
  • (In progress) Wiring the parsed value into MavenExecutionRequest via
    MavenInvoker.populateRequest(...).
  • (In progress) Adding isPrintBuildOrder()/setPrintBuildOrder(boolean) to
    MavenExecutionRequest/DefaultMavenExecutionRequest.
  • (In progress) In DefaultMaven.doExecute(...), after the authoritative buildGraph(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:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the Core IT successfully.

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.

  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
  • In any other case, please file an Apache Individual Contributor License Agreement.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AbdelHamdyGhanem
MNG-7884: Add --print-build-order CLI option (parsing only, not yet w…
8dd8ad7
…ired to request)
gnodet
gnodet reviewed Jul 13, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gnodet added a commit to gnodet/maven that referenced this pull request Jul 13, 2026
@gnodet
chore: update PR review loop state — reviewed apache#12486, apache#12482
4b29fc6
, apache#12483
@cstamas

This comment was marked as off-topic.

Sign in to view
AbdelHamdyGhanem added 2 commits July 13, 2026 17:42
@AbdelHamdyGhanem
Update MavenOptions.java
4f7649f
@AbdelHamdyGhanem
Update MavenOptions.java
b28ea7b
gnodet
gnodet reviewed Jul 13, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Feature not wired up (high) — the option is parsed but still never consumed anywhere in the execution path. mvn --print-build-order would accept the flag but silently do nothing.
  2. No tests (medium) — at minimum a parsing test for CommonsCliMavenOptions would 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gnodet added a commit to gnodet/maven that referenced this pull request Jul 13, 2026
@gnodet
chore: update PR review loop state — re-reviewed apache#12486
ddb38ca
gnodet
gnodet requested changes Jul 24, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The CLI option parsing for --print-build-order / -pbo correctly follows existing Maven conventions (the @Nonnull Optional<Boolean> pattern, returnFirstPresentOrEmpty delegation). However, the feature is incomplete:

  1. Option never consumed (CommonsCliMavenOptions.java:105): The printBuildOrder() option is parsed at the CLI layer but never consumed by any execution code. There is no isPrintBuildOrder()/setPrintBuildOrder(boolean) on MavenExecutionRequest, no wiring in MavenInvoker.populateRequest(), and no print-and-exit logic in DefaultMaven.doExecute(). Running mvn --print-build-order would silently accept and ignore the flag.

  2. No tests: No unit or integration tests are included. At minimum, a parsing test confirming -pbo / --print-build-order is correctly recognized would be expected.

The PR description explicitly labels the wiring as "(In progress)" but the PR is not marked as draft. Consider converting to draft until the feature is complete, or adding the remaining implementation (request wiring + execution logic + tests).

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gnodet
gnodet reviewed Aug 24, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR adds CLI option parsing for --print-build-order / -pbo but the feature is currently non-functional — the option is parsed and silently ignored because no execution wiring exists. The PR has been stale for one month since the last CHANGES_REQUESTED review.

Findings

1. [HIGH] Option parsed but never consumed
The --print-build-order / -pbo option is registered at the CLI layer (CommonsCliMavenOptions) and propagated through MavenOptions, but the execution pipeline never reads it:

  • No isPrintBuildOrder() / setPrintBuildOrder(boolean) on MavenExecutionRequest / DefaultMavenExecutionRequest
  • No wiring in MavenInvoker.populateRequest()
  • No print-and-exit logic in DefaultMaven.doExecute()

Running mvn --print-build-order will silently accept and ignore the flag. The PR description itself labels these three wiring pieces as "(In progress)".

2. [MEDIUM] No tests
No test files are added or modified — neither a parsing test for the new option nor an integration test exercising the print-and-exit behavior.

3. [MEDIUM] PR not marked as draft
The PR description explicitly labels multiple implementation pieces as "(In progress)", but the PR is not marked as a draft. Consider converting to draft until the wiring is complete.

📋 PR Metadata

Aspect Current Suggested
Category (unlabeled) feature
Labels (none) enhancement
Milestone (none) 4.x

🔀 Backport Status

Backport not needed — this is a new feature.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet gnodet added enhancement New feature or request mvn4 labels Oct 14, 2026
@gnodet gnodet changed the title MNG-7884: Add --print-build-order option to print reactor build order without building #8733: Add --print-build-order option to print reactor build order without building Nov 9, 2026
gnodet-bot
gnodet-bot reviewed Nov 26, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI parsing layer for --print-build-order / -pbo is correct — @Nonnull Optional<Boolean> pattern, returnFirstPresentOrEmpty delegation, option registration — all follow Maven conventions. However, the feature is non-functional and the PR is not ready to merge.

1. [HIGH] Option parsed but never consumed
printBuildOrder() is defined in the API and parsed at the CLI layer, but the execution pipeline is entirely absent:

  • No isPrintBuildOrder() / setPrintBuildOrder(boolean) on MavenExecutionRequest / DefaultMavenExecutionRequest
  • No wiring in MavenInvoker.populateRequest()
  • No print-and-exit logic in DefaultMaven.doExecute() after buildGraph(session)

Running mvn --print-build-order will silently accept the flag and do nothing. The PR description itself marks all three wiring pieces as "(In progress)".

2. [MEDIUM] Optional<Boolean> return contract — false case is dead code
The @return Javadoc in MavenOptions.java documents a false case, but CommonsCliMavenOptions.printBuildOrder() can only ever return Optional.of(Boolean.TRUE) or Optional.empty() — Optional.of(Boolean.FALSE) is unreachable. The false branch is misleading in the Javadoc. This is a boolean presence flag: set → true, absent → empty. The @return should drop the false branch to match the actual contract.

3. [MEDIUM] No tests
No unit or integration tests are included. At minimum, a CommonsCliMavenOptionsTest asserting that -pbo / --print-build-order is correctly parsed into Optional.of(Boolean.TRUE) can be added now, before the full wiring is complete.

4. [LOW] PR not marked as draft
The PR description explicitly labels three implementation pieces as "(In progress)" but the PR is open (not draft). Convert to draft until the wiring is complete so the CI queue and maintainer attention are not consumed by an incomplete feature.


Please mark as draft and add the missing wiring + tests before requesting a final review.

generated by an AI agent, Hermès

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvn/MavenOptions.java
Comment on lines +108 to +109
* @return an {@link Optional} containing true if the reactor build order should be printed
* and the build skipped, false if not, or empty if not specified.

@gnodet-bot gnodet-bot Nov 26, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Misleading @return contract — false is unreachable: The implementation in CommonsCliMavenOptions can only return Optional.of(Boolean.TRUE) or Optional.empty(). The false if not branch is dead code that will never be observed by callers.

Suggestion: drop the false branch from the Javadoc to match the actual contract:

Suggested change
* @return an {@link Optional} containing true if the reactor build order should be printed
* and the build skipped, false if not, or empty if not specified.
* @return an {@link Optional} containing true if the reactor build order should be printed
* and the build skipped, or empty if not specified.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/CommonsCliMavenOptions.java
if (commandLine.hasOption(CLIManager.PRINT_BUILD_ORDER)) {
return Optional.of(Boolean.TRUE);
}
return Optional.empty();

@gnodet-bot gnodet-bot Nov 26, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ false return case is unreachable: The flag is a boolean presence flag — if present on the command line it returns Optional.of(true), otherwise Optional.empty(). There is no code path that returns Optional.of(false). This matches the pattern of failFast() / failAtEnd() / failNever() — all presence-only flags. The Javadoc @return in MavenOptions.java should be updated to match.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gnodet gnodet gnodet requested changes
+1 more reviewer
@gnodet-bot gnodet-bot gnodet-bot left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request mvn4

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[MNG-7884] Add a command line option to just print the reactor build order

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@AbdelHamdyGhanem @cstamas @gnodet @gnodet-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.