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 37cce8b commit 43d3519
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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 @@ -100,7 +101,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 @@ -172,6 +179,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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void testInJarResolverSnapshotLocal() {
ArrayList<URL> urlArrayList = new ArrayList<URL>();
urlArrayList.add(classLoader.getResource("BOOT-INF/classes/KIE-INF/lib/kjar-1.0.0-SNAPSHOT.pom"));

InJarArtifactResolver inJarArtifactResolver = new InJarArtifactResolver(classLoader, releaseId, true);
InJarArtifactResolver inJarArtifactResolver = new InJarArtifactResolver(classLoader, releaseId);
InJarArtifactResolver spy = Mockito.spy(inJarArtifactResolver);
doReturn(urlArrayList).when(spy).buildResources(any());

Expand All @@ -50,7 +50,7 @@ public void testInJarResolverSnapshotExternal() {
ClassLoader classLoader = getClass().getClassLoader();
AFReleaseId releaseId = new AFReleaseIdImpl("org.jbpm", "kjar", "1.0.0-SNAPSHOT", "jar");

InJarArtifactResolver inJarArtifactResolver = new InJarArtifactResolver(classLoader, releaseId, true);
InJarArtifactResolver inJarArtifactResolver = new InJarArtifactResolver(classLoader, releaseId );
InJarArtifactResolver spy = Mockito.spy(inJarArtifactResolver);

ArrayList<URL> urlArrayList = new ArrayList<URL>();
Expand Down

0 comments on commit 43d3519

Please sign in to comment.