gnodet-bot commented on code in PR #13672:
URL: https://github.com/apache/maven/pull/13672#discussion_r4345954364
##########
impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java:
##########
@@ -916,6 +916,10 @@ public Map<String, Artifact> getArtifactMap() {
}
return artifactMap;
}
+ /** @see ArtifactMaps#byDependencyConflictId(java.util.Collection) @since
4.1.0 */
Review Comment:
⚠️ **`@see` references a package-private class** — `ArtifactMaps` is `final
class` (no `public` modifier), so this tag is invisible to external Javadoc
consumers and will generate a broken Javadoc link. Replace with inline prose:
```suggestion
/**
* Returns a map of artifacts keyed by {@link
org.apache.maven.artifact.Artifact#getDependencyConflictId()}
* (groupId:artifactId:type[:classifier]). Unlike {@link
#getArtifactMap()}, this disambiguates artifacts
* that share the same groupId and artifactId but differ by classifier
(MNG-5552).
*
* @since 4.1.0
*/
```
##########
impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java:
##########
@@ -916,6 +916,10 @@ public Map<String, Artifact> getArtifactMap() {
}
return artifactMap;
}
+ /** @see ArtifactMaps#byDependencyConflictId(java.util.Collection) @since
4.1.0 */
+ public Map<String, Artifact> getArtifactMapByDependencyConflictId() {
+ return ArtifactMaps.byDependencyConflictId(getArtifacts());
Review Comment:
⚠️ **No caching** — `getArtifactMap()` (line 913–917) caches via the
`artifactMap` field and is invalidated in
`setArtifacts()`/`setResolvedArtifacts()`. This new method rebuilds a
`LinkedHashMap` on every call, which is inconsistent and potentially expensive
for large projects. Follow the same pattern:
```suggestion
if (artifactMapByDependencyConflictId == null) {
artifactMapByDependencyConflictId =
ArtifactMaps.byDependencyConflictId(getArtifacts());
}
return artifactMapByDependencyConflictId;
```
(Declare `private Map<String, Artifact> artifactMapByDependencyConflictId;`
alongside `artifactMap`, and add `artifactMapByDependencyConflictId = null;` in
both `setArtifacts()` and `setResolvedArtifacts()`.)
--
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]