Skip to content

Commit

Permalink
locate pom with snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Fanjul committed Aug 1, 2024
1 parent 86b719a commit 3bc0cb5
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.regex.Pattern;

import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
Expand Down Expand Up @@ -102,7 +103,13 @@ private boolean isInJarStructuredFolder(String name, String type) {
}

private PomParser buildPomParser(AFReleaseId releaseId) {
List<URL> url = effectivePoms.stream().filter(e -> e.getFile().endsWith(toFile(releaseId, "pom"))).collect(toList());
final String pomName = toFile(releaseId, "pom");
List<URL> url = effectivePoms.stream().filter(e -> e.getFile().endsWith(pomName)).collect(toList());
if (url.isEmpty() && releaseId.getVersion().endsWith("-SNAPSHOT")) {
url = effectivePoms.stream().filter(e -> {
return Pattern.compile(toFileSnapshotRegex(releaseId, "pom")).matcher(e.getFile()).find();
}).collect(toList());
}
if (url.isEmpty()) {
return null;
}
Expand Down Expand Up @@ -174,6 +181,10 @@ private String toFile(AFReleaseId releaseId, String type) {
return releaseId.getArtifactId() + "-" + releaseId.getVersion() + "." + type;
}

private String toFileSnapshotRegex(AFReleaseId releaseId, String type) {
return releaseId.getArtifactId() + "-" + releaseId.getVersion().replace("-SNAPSHOT", ".*") + "." + type + "$";
}

@Override
public List<DependencyDescriptor> getArtifactDependecies(String artifactName) {
AFReleaseId releaseId = new AFReleaseIdImpl(artifactName);
Expand Down

0 comments on commit 3bc0cb5

Please sign in to comment.