Skip to content

[MNG-7991] refactor "aggregator" goal feature #8718

Open

Description

@jira-importer

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 @aggregator and 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

  1. gnodet commented on Oct 30, 2026

    @gnodet
    Contributor

    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=true bundles 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 the before:/after: phase prefixes and the all / each reactor-scoped phases:

    • A goal bound to after:all on the root project runs exactly once, after every subproject has completed its full build — enforced by the build plan DAG, not a global lock.
    • This works whether the goal is invoked via CLI or lifecycle-bound, with no need for <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:all guarantees 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 -T multithreaded builder

    The concurrent builder does not use aggregatorLock at 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 install no longer silently drop later phases.

    5. MNG-7672 / #8780 — Aggregate goal in submodule forks the whole reactor

    Closed/fixed independently.


    ⚠️ Partially addressed / workaround available

    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 @After constraints can replace @Execute and eliminate the fork entirely, but existing plugins using @Execute still 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=true

    All Apache Maven plugins (javadoc:aggregate, dependency:analyze-dep-mgt, site:stage, etc.) still declare @Mojo(aggregator = true). They do not use after:all. Until they are migrated, users get the old behavior unless they manually reconfigure phase bindings.

    2. Formal deprecation of aggregator=true and @Execute

    No deprecation marker or warning has been added yet. Plugin authors have no indication that these are superseded.

    3. The aggregator flag decomposition — full implementation

    As described in PR #13330, aggregator=true bundles four behaviors:

    Behavior Maven 4 replacement Status
    Execution scope (run once on root) after:all / before:all phase Available (concurrent builder only)
    Dependency resolution scope @Resolution per-field injection Available
    Exclusive write lock (-T) DAG edges (concurrent builder) Available
    Fork scope (@Execute) @After constraints Available but not widely adopted

    The internal mapping of aggregator=true to 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; @After constraints are the replacement path but @Execute machinery has not been deprecated or removed.


    Recommended next steps

    1. Migrate Apache Maven plugins from aggregator=true + @Execute to after:all + @After, starting with javadoc, dependency, and site plugins.
    2. Add deprecation warnings in Maven core when aggregator=true or @Execute is used with a v4 plugin descriptor.
    3. Document the migration on maven.apache.org (PR [MNG-7991] Document aggregator goal lifecycle behavior and design spe… #13330 adds the architecture spec; a migration guide for plugin authors would complete this).
    4. Internally map aggregator=true to 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.

  2. added a commit that references this issue on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:majorMajor loss of functiontrackingTracking issue with sub-issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions