diff --git a/prospero-common/src/main/java/org/wildfly/prospero/galleon/ChannelMavenArtifactRepositoryManager.java b/prospero-common/src/main/java/org/wildfly/prospero/galleon/ChannelMavenArtifactRepositoryManager.java index 9a9cb17cb..7afbb873f 100644 --- a/prospero-common/src/main/java/org/wildfly/prospero/galleon/ChannelMavenArtifactRepositoryManager.java +++ b/prospero-common/src/main/java/org/wildfly/prospero/galleon/ChannelMavenArtifactRepositoryManager.java @@ -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)) { diff --git a/prospero-common/src/main/java/org/wildfly/prospero/galleon/MavenArtifactMapper.java b/prospero-common/src/main/java/org/wildfly/prospero/galleon/MavenArtifactMapper.java index eeefb0901..93b2e20e7 100644 --- a/prospero-common/src/main/java/org/wildfly/prospero/galleon/MavenArtifactMapper.java +++ b/prospero-common/src/main/java/org/wildfly/prospero/galleon/MavenArtifactMapper.java @@ -56,7 +56,7 @@ private String wrapNull(String value) { public List 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()); } diff --git a/prospero-common/src/test/java/org/wildfly/prospero/galleon/MavenArtifactMapperTest.java b/prospero-common/src/test/java/org/wildfly/prospero/galleon/MavenArtifactMapperTest.java index 22c07d67c..031f5fe84 100644 --- a/prospero-common/src/test/java/org/wildfly/prospero/galleon/MavenArtifactMapperTest.java +++ b/prospero-common/src/test/java/org/wildfly/prospero/galleon/MavenArtifactMapperTest.java @@ -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 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);