slachiewicz opened a new issue, #14176:
URL: https://github.com/apache/maven/issues/14176

   ### Background
   
   `LifecycleExecutor.calculateForkedExecutions(MojoExecution, MavenSession)` 
is public API, commented "used by the site plugin 3.x" in 
[LifecycleExecutor.java](https://github.com/apache/maven/blob/master/impl/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java).
 `maven-reporting-exec` calls it once per report mojo while preparing reports.
   
   ### Problem
   
   The public entry point starts with an empty already-planned set:
   
   - Maven 3.10.x: 
[DefaultLifecycleExecutionPlanCalculator.java](https://github.com/apache/maven/blob/maven-3.10.x/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java)
 creates `new HashSet<MojoDescriptor>()`, used only for cycle detection; it has 
no relation to the project's main execution plan.
   - master / 4.0.x: 
[DefaultLifecycleExecutionPlanCalculator.java](https://github.com/apache/maven/blob/master/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java)
 passes `new HashSet<>()` from the public method. The 
`alreadyPlannedExecutions` set introduced for MNG-7163 is seeded only in the 
internal `setupMojoExecutions` path, which external callers never go through.
   
   As a result, in `mvn clean test site` every report forks the phases it needs 
again, even though the main lifecycle already planned and ran them. With 
javadoc and surefire-report configured, resources/compile run three times and 
testResources/testCompile/test twice in one session (MSHARED-1044, 
[maven-reporting-exec#91](https://github.com/apache/maven-reporting-exec/issues/91)).
   
   ### Proposal
   
   Make the already-planned/executed mojos visible to callers of the public API:
   
   1. Record the mojo descriptor IDs of a project's execution plan in session 
data when `setupMojoExecutions` runs, and add each forked mojo's ID when it 
executes.
   2. Have the public `calculateForkedExecutions` seed its tracking set from 
that session data, so external callers get the same skipping behaviour core 
already gets internally.
   3. Keep the existing method signature; no new public API is needed for 
current callers, and 3.10.x, 4.0.x and master should behave alike.
   
   ### Workaround today
   
   
[maven-reporting-exec#194](https://github.com/apache/maven-reporting-exec/pull/194)
 recomputes the main plan with `calculateExecutionPlan(session, 
goals-before-site)` and filters forked mojos itself. That is an approximation: 
it cannot see the real plan, extensions that modify it, or mojos already 
executed by other plugins in the session.
   


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