Skip to content

Commit

Permalink
[MNG-8229] CI Friendly versions confuse model pool
Browse files Browse the repository at this point in the history
Fixing the method (there is one GA inside reactor),
but this still does not fix the issue, now it fails
elsewhere.

The problem in short is CI friendly version and its
half-assed solution as model version "suddenly" change
from file-activated models to effective ones.

---

https://issues.apache.org/jira/browse/MNG-8229
  • Loading branch information
cstamas committed Aug 29, 2024
1 parent c0813a2 commit a9221f7
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.maven.project;

import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -48,13 +49,20 @@ class ReactorModelPool {
* @throws IllegalStateException if version was null and multiple modules share the same groupId + artifactId
*/
public Model get(String groupId, String artifactId, String version) {
return modelsByGa.getOrDefault(new GAKey(groupId, artifactId), Collections.emptySet()).stream()
.filter(m -> version == null || version.equals(getVersion(m)))
.reduce((a, b) -> {
throw new IllegalStateException(
"Multiple modules with key " + a.getGroupId() + ':' + a.getArtifactId());
})
.orElse(null);
Collection<Model> models = modelsByGa.getOrDefault(new GAKey(groupId, artifactId), Collections.emptySet());
if (models.isEmpty()) {
return null;
} else if (models.size() == 1) {
return models.iterator().next();
} else {
return models.stream()
.filter(m -> version == null || version.equals(getVersion(m)))
.reduce((a, b) -> {
throw new IllegalStateException(
"Multiple modules with key " + a.getGroupId() + ':' + a.getArtifactId());
})
.orElse(null);
}
}

private String getVersion(Model model) {
Expand Down

0 comments on commit a9221f7

Please sign in to comment.