Skip to content

Commit

Permalink
Handle resolving galleon artifacts without default version
Browse files Browse the repository at this point in the history
  • Loading branch information
spyrkob committed Aug 4, 2023
1 parent 878d81b commit 2687331
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ private org.wildfly.channel.MavenArtifact resolveFromPreparedManifest(MavenArtif
}

private boolean requiresChannel(MavenArtifact artifact) {
// if the Galleon pack hasn't defined the version, it needs to come from channel
if (artifact.getVersion() == null || artifact.getVersion().isEmpty()) {
return true;
}
boolean requireChannel = Boolean.parseBoolean(artifact.getMetadata().get(REQUIRE_CHANNEL_FOR_ALL_ARTIFACT));
try {
if (!requireChannel && ! fpRequireChannel(artifact)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private String wrapNull(String value) {

public List<ArtifactCoordinate> toChannelArtifacts() {
return galleonArtifacts.stream()
.map(a -> new ArtifactCoordinate(a.getGroupId(), a.getArtifactId(), a.getExtension(), a.getClassifier(), a.getVersion()))
.map(a -> new ArtifactCoordinate(a.getGroupId(), a.getArtifactId(), a.getExtension(), a.getClassifier(), a.getVersion()==null?"":a.getVersion()))
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ public void testArtifactNotFoundInMapper() throws Exception {
.isThrownBy(()->mavenArtifactMapper.get(new ArtifactCoordinate("foo.bar", "idontexist", "jar", "", "")));
}

@Test
public void testArtifactWithoutVersionIsMappedWithEmptyString() throws Exception {
final List<org.jboss.galleon.universe.maven.MavenArtifact> galleonArtifacts = Arrays.asList(
galleonArtifact("foo.bar", "test1", "jar").setVersion(null));

final MavenArtifactMapper mavenArtifactMapper = new MavenArtifactMapper(galleonArtifacts);
assertThat(mavenArtifactMapper.toChannelArtifacts())
.contains(new ArtifactCoordinate("foo.bar", "test1", "jar", "", ""));
}

private org.jboss.galleon.universe.maven.MavenArtifact galleonArtifact(String groupId, String artifactId, String extension) {
final org.jboss.galleon.universe.maven.MavenArtifact galleonArtifact = new org.jboss.galleon.universe.maven.MavenArtifact();
galleonArtifact.setGroupId(groupId);
Expand Down

0 comments on commit 2687331

Please sign in to comment.