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

   ## Problem
   
   When running a build with `-pl` (project list selector), the progress 
counter shows the project's position in the **full** reactor rather than its 
position within the selected subset:
   
   ```
   $ mvn install -pl module-foo,module-bar   # these are modules 14 and 15 in a 
17-module reactor
   [INFO] Building module-foo 1.0.0   [14/17]
   [INFO] Building module-bar 1.0.0   [15/17]
   ```
   
   The expected output is:
   ```
   [INFO] Building module-foo 1.0.0   [1/2]
   [INFO] Building module-bar 1.0.0   [2/2]
   ```
   
   ## Root cause
   
   PR #804 (MNG-7098) changed `ExecutionEventLogger.sessionStarted()` to:
   
   ```java
   final List<MavenProject> allProjects = event.getSession().getAllProjects();
   currentVisitedProjectCount = allProjects.size() - projects.size();
   totalProjects = allProjects.size();
   ```
   
   This pre-offsets the counter and uses the full reactor total so that `-rf` 
(resume-from) shows the correct absolute position. But it also applies to plain 
`-pl` selections, where it makes no sense: the user is deliberately running a 
subset and wants to see `[1/N]` progress, not the project's coordinates in a 
reactor they're not building.
   
   ## Proposed fix
   
   Distinguish the two cases:
   
   - **`-rf` / resume-from**: keep the current behavior — full-reactor 
numbering with an offset makes sense here because the user knows they are 
resuming a partial build.
   - **`-pl` / project selection without resume**: use `projects.size()` as 
`totalProjects` and start `currentVisitedProjectCount` at 0 — the user is 
building a chosen subset and wants relative progress.
   
   The distinction is accessible via 
`event.getSession().getRequest().getResumeFrom()` (non-null ⟹ resuming).
   
   ```java
   final List<MavenProject> allProjects = event.getSession().getAllProjects();
   final boolean isResuming = event.getSession().getRequest().getResumeFrom() 
!= null
           && !event.getSession().getRequest().getResumeFrom().isEmpty();
   if (isResuming) {
       currentVisitedProjectCount = allProjects.size() - projects.size();
       totalProjects = allProjects.size();
   } else {
       currentVisitedProjectCount = 0;
       totalProjects = projects.size();
   }
   ```
   
   The same logic applies to both 
`impl/maven-cli/.../cling/event/ExecutionEventLogger.java` and 
`compat/maven-embedder/.../cli/event/ExecutionEventLogger.java`.


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