Repository navigation
Description
Hervé Boutemy opened MNG-7991 and commented
aggregation was added in early Maven 2 stages with MNG-250, not really documented AFAIK, but highly visible through @Mojo(aggregator=true) Mojo annotation
there are multiple shortcomings found over time:
-
discrepancy between CLI and lifecycle use:
- CLI executes aggregator-marked goal only on root module (skips goal execution in sub-modules) and after executing the lifecycle to all modules
- lifecycle-bound goal executes goal on each and every module, during normal lifecycle run on each module: not even sure aggregator configuration changes anything
-
forked lifecycle execution vs second execution in modules
-
sometimes, instead of executing aggregate goal before building modules, it would be useful to execute aggregate after building modules (to aggregate some results built in each module)
notice that this looks also like the need for "execute at end" as found in install/deploy
we probably need to better document what aggregate currently does and define what should be the target: perhaps refactoring will require new mechanisms that we won't call aggregator, like MNG-5665...
edge case: aggregating reports for maven-site-plugin (launched by maven-reporting-exec, hence quite independent from associated reporting goals even if we expect some consistency between site reports and reporting goals)
Affects: 4.x / Backlog
Issue Links:
-
MNG-2184 Possible problem with
@aggregatorand forked lifecycles
("contains") -
MNG-6336 Aggregator Mojo should be executed only once even when part of the lifecycle
("incorporates") -
MNG-250 make aggregation feasible
("is caused by") -
MNG-5665 Advanced Lifecycle Handling
-
MNG-7163 Aggregating Mojo re-executes goals for child modules that are already executed
-
MNG-7672 Aggregate goals executed in a submodule forks the whole reactor
-
MNG-2180 Allow aggregation mojos to access plugin configurations
-
MNG-4504 Disallowing all aggregator bindings to any lifecycle is too broad
-
MNG-8337 aggregator goal called from CLI shows an additional module at end (= first module twice)
-
MNG-7900 wrapper lifecycle in multi module project should be executed only in root module
Activity
gnodet commentedon Oct 30, 2026
Current State Assessment (Maven 4.x)
With the Maven 4 concurrent builder (
-b concurrent) now available, several of the shortcomings described in this issue have been addressed. Here is a structured view of what is solved, what is partially addressed, and what remains open.✅ Solved by the concurrent builder
1. CLI vs. lifecycle discrepancy (#7529 / MNG-6336)
The root cause is that
aggregator=truebundles two unrelated concerns: execution scope (run once on the root) and ordering (run after all modules are built). The concurrent builder separates these cleanly via thebefore:/after:phase prefixes and theall/eachreactor-scoped phases:after:allon the root project runs exactly once, after every subproject has completed its full build — enforced by the build plan DAG, not a global lock.<inherited>false</inherited>.Note:
before:/after:phases require the concurrent builder (-b concurrent). They work with any POM model version (4.0.0 or 4.1.0).2. Execution timing: aggregator runs before children are built
after:allguarantees that child module outputs (compiled classes, packaged artifacts) exist when the aggregator runs. The workaround of placing an artificial "distribution" child module last in reactor order is no longer needed.3. Reactor-wide write lock in
-Tmultithreaded builderThe concurrent builder does not use
aggregatorLockat all — it relies on DAG edges for ordering. No global lock, no serialization of the build.4. Concurrent builder task segment merging (#13529)
Fixed by #13532. Overlapping task segments like
mvn package installno longer silently drop later phases.5. MNG-7672 / #8780 — Aggregate goal in submodule forks the whole reactor
Closed/fixed independently.
CLI vs. lifecycle discrepancy — legacy builders
The fix only works with
-b concurrent. The singlethreaded (default) and multithreaded (-T) builders still exhibit the original discrepancy. Plugin authors targeting Maven 4 with the concurrent builder can migrate now; everyone else is still affected.MNG-7163 / #8291 — Aggregator re-executes already-completed child module goals
This is about forked lifecycle execution causing duplicate goal runs. The concurrent builder's
@Afterconstraints can replace@Executeand eliminate the fork entirely, but existing plugins using@Executestill trigger the old behavior. No code change in Maven core has fixed this for legacy plugins.❌ Still open / not yet addressed
1. Existing plugins using
aggregator=trueAll Apache Maven plugins (javadoc:aggregate, dependency:analyze-dep-mgt, site:stage, etc.) still declare
@Mojo(aggregator = true). They do not useafter:all. Until they are migrated, users get the old behavior unless they manually reconfigure phase bindings.2. Formal deprecation of
aggregator=trueand@ExecuteNo deprecation marker or warning has been added yet. Plugin authors have no indication that these are superseded.
3. The
aggregatorflag decomposition — full implementationAs described in PR #13330,
aggregator=truebundles four behaviors:after:all/before:allphase@Resolutionper-field injection-T)@Execute)@AfterconstraintsThe internal mapping of
aggregator=trueto equivalent DAG constraints (so legacy plugins benefit automatically) is the remaining core work, targeted at Maven 5.x per the current plan.4. MNG-5665 / #6657 — Advanced Lifecycle Handling
The broader lifecycle handling improvements are not yet done.
5. MNG-2184 / #4453 — Forked lifecycles with aggregator
Still open;
@Afterconstraints are the replacement path but@Executemachinery has not been deprecated or removed.Recommended next steps
aggregator=true+@Executetoafter:all+@After, starting with javadoc, dependency, and site plugins.aggregator=trueor@Executeis used with a v4 plugin descriptor.aggregator=trueto DAG constraints in the concurrent builder for Maven 4.x, so legacy plugins benefit without changes (targeted roadmap item).PR #13330 adds architectural documentation covering this analysis and the recommended migration path.
[MNG-7991] Document aggregator goal lifecycle behavior and design spe… (