Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Dec 18, 2023
1 parent c01dad8 commit b188bfc
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;

import org.apache.maven.model.Model;
import org.apache.maven.model.building.ArtifactModelSource;
Expand Down Expand Up @@ -129,7 +128,7 @@ private Model loadPom(
throws ArtifactDescriptorException {
RequestTrace trace = RequestTrace.newChild(request.getTrace(), request);

Set<String> visited = new LinkedHashSet<>();
LinkedHashSet<String> visited = new LinkedHashSet<>();
for (Artifact a = request.getArtifact(); ; ) {
Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifactUnconditionally(a);
try {
Expand Down Expand Up @@ -239,15 +238,26 @@ private Model loadPom(

Artifact relocatedArtifact = getRelocation(session, result, model);
if (relocatedArtifact != null) {
result.addRelocation(a);
a = relocatedArtifact;
result.setArtifact(a);
if (withinSameGav(relocatedArtifact, a)) {
result.setArtifact(relocatedArtifact);
return model; // they share same model
} else {
result.addRelocation(a);
a = relocatedArtifact;
result.setArtifact(a);
}
} else {
return model;
}
}
}

private boolean withinSameGav(Artifact a1, Artifact a2) {
return Objects.equals(a1.getGroupId(), a2.getGroupId())
&& Objects.equals(a1.getArtifactId(), a2.getArtifactId())
&& Objects.equals(a1.getVersion(), a2.getVersion());
}

private Properties toProperties(Map<String, String> dominant, Map<String, String> recessive) {
Properties props = new Properties();
if (recessive != null) {
Expand Down

0 comments on commit b188bfc

Please sign in to comment.