elharo opened a new issue, #270:
URL: https://github.com/apache/maven-remote-resources-plugin/issues/270

   ## Summary
   Referencing `$projects` (or `$projectsSortedByOrganization`) in a template 
triggers `getProjects()`, which performs a full `projectBuilder.build(...)` for 
**every** dependency artifact — not just the reactor projects.
   
   
`src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java:770-783,
 533-556`
   
   ```java
   public Object internalGet(String key) {
       Object result = super.internalGet(key);
       if (result == null && key != null && key.startsWith(KEY_PROJECTS) && 
containsKey(key)) {
           List<MavenProject> projects = getProjects();
           put(KEY_PROJECTS, projects);
           put(KEY_PROJECTS_ORGS, getProjectsSortedByOrganization(projects));
           return super.internalGet(key);
       }
       return result;
   }
   ```
   
   `getProjects()` builds a `ProjectBuildingRequest` and calls 
`projectBuilder.build(artifact, req)` for each artifact in the (filtered) 
dependency set (`:541-556`), then sorts the results.
   
   ## Impact
   - For projects with hundreds of dependencies, `$projects` costs hundreds of 
expensive model builds (POM fetch + parent chain + property resolution each).
   - The computation is eager for **both** `projects` and 
`projectsSortedByOrganization` even when a template references only one of them.
   - It is recomputed whenever a new `projects*` key is accessed before caching 
settles, though the first computation is the dominant cost.
   
   The lazy mechanism is intentional, but the cost per use is high and worth 
documenting or optimizing (e.g. only build models for artifacts not already in 
the reactor, or cache across executions).
   
   ## Suggested fix
   Consider reusing reactor projects from `mavenSession.getProjects()` when the 
artifact matches, building only genuinely external artifacts, and computing the 
org-sorted map only when actually referenced.


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