gnodet commented on issue #8718:
URL: https://github.com/apache/maven/issues/8718#issuecomment-6533617390

   ## 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 #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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to