diff --git a/core/src/main/java/org/wildfly/channel/ChannelSession.java b/core/src/main/java/org/wildfly/channel/ChannelSession.java index 2b23aaf6..70fe033b 100644 --- a/core/src/main/java/org/wildfly/channel/ChannelSession.java +++ b/core/src/main/java/org/wildfly/channel/ChannelSession.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.List; +import java.util.Objects; import java.util.Optional; import org.wildfly.channel.spi.MavenVersionsResolver; @@ -55,10 +56,16 @@ public ChannelSession(List channels, MavenVersionsResolver.Factory fact * @param artifactId - required * @param extension - can be null * @param classifier - can be null + * @param baseVersion - required * @return the Maven Artifact (with a file corresponding to the artifact). * @throws UnresolvedMavenArtifactException if the latest version can not be resolved or the artifact itself can not be resolved */ - public MavenArtifact resolveMavenArtifact(String groupId, String artifactId, String extension, String classifier) throws UnresolvedMavenArtifactException { + public MavenArtifact resolveMavenArtifact(String groupId, String artifactId, String extension, String classifier, String baseVersion) throws UnresolvedMavenArtifactException { + requireNonNull(groupId); + requireNonNull(artifactId); + // baseVersion is not used at the moment but will provide essential to support advanced use cases to determine multiple streams of the same Maven component. + requireNonNull(baseVersion); + Channel.ResolveLatestVersionResult result = findChannelWithLatestVersion(groupId, artifactId, extension, classifier); String latestVersion = result.version; Channel channel = result.channel; diff --git a/core/src/test/java/org/wildfly/channel/ChannelRecorderTestCase.java b/core/src/test/java/org/wildfly/channel/ChannelRecorderTestCase.java index 28bf7fe9..04b2cf1c 100644 --- a/core/src/test/java/org/wildfly/channel/ChannelRecorderTestCase.java +++ b/core/src/test/java/org/wildfly/channel/ChannelRecorderTestCase.java @@ -75,12 +75,12 @@ public void testChannelRecorder() throws IOException, UnresolvedMavenArtifactExc .thenReturn(mock(File.class)); try (ChannelSession session = new ChannelSession(channels, factory)) { - session.resolveMavenArtifact("org.wildfly", "wildfly-ee-galleon-pack", null, null); - session.resolveMavenArtifact("org.wildfly.core", "wildfly.core.cli", null, null); - session.resolveMavenArtifact("io.undertow", "undertow-core", null, null); - session.resolveMavenArtifact("io.undertow", "undertow-servlet", null, null); + session.resolveMavenArtifact("org.wildfly", "wildfly-ee-galleon-pack", null, null, "20.0.0.Final"); + session.resolveMavenArtifact("org.wildfly.core", "wildfly.core.cli", null, null, "15.0.0.Final"); + session.resolveMavenArtifact("io.undertow", "undertow-core", null, null, "1.0.0.Final"); + session.resolveMavenArtifact("io.undertow", "undertow-servlet", null, null, "1.0.0.Final"); // This should not be recorded, size should remain 4. - session.resolveMavenArtifact("io.undertow", "undertow-servlet", null, null); + session.resolveMavenArtifact("io.undertow", "undertow-servlet", null, null, "1.0.0.Final"); Channel recordedChannel = session.getRecordedChannel(); System.out.println(ChannelMapper.toYaml(recordedChannel)); diff --git a/core/src/test/java/org/wildfly/channel/ChannelSessionTestCase.java b/core/src/test/java/org/wildfly/channel/ChannelSessionTestCase.java index 5dc8d83e..e14d55f9 100644 --- a/core/src/test/java/org/wildfly/channel/ChannelSessionTestCase.java +++ b/core/src/test/java/org/wildfly/channel/ChannelSessionTestCase.java @@ -107,7 +107,7 @@ public void testResolveLatestMavenArtifact() throws UnresolvedMavenArtifactExcep try (ChannelSession session = new ChannelSession(channels, factory)) { - MavenArtifact artifact = session.resolveMavenArtifact("org.wildfly", "wildfly-ee-galleon-pack", null, null); + MavenArtifact artifact = session.resolveMavenArtifact("org.wildfly", "wildfly-ee-galleon-pack", null, null, "25.0.0.Final"); assertNotNull(artifact); assertEquals("org.wildfly", artifact.getGroupId()); @@ -138,7 +138,7 @@ public void testResolveLatestMavenArtifactThrowUnresolvedMavenArtifactException( try (ChannelSession session = new ChannelSession(channels, factory)) { try { - session.resolveMavenArtifact("org.wildfly", "wildfly-ee-galleon-pack", null, null); + session.resolveMavenArtifact("org.wildfly", "wildfly-ee-galleon-pack", null, null, "25.0.0.Final"); fail("Must throw a UnresolvedMavenArtifactException"); } catch (UnresolvedMavenArtifactException e) { // pass @@ -167,7 +167,7 @@ public void testResolveDirectMavenArtifact() throws UnresolvedMavenArtifactExcep try (ChannelSession session = new ChannelSession(channels, factory)) { Assertions.assertThrows(UnresolvedMavenArtifactException.class, () -> { - session.resolveMavenArtifact("org.bar", "bar", null, null); + session.resolveMavenArtifact("org.bar", "bar", null, null, "25.0.0.Final"); }); MavenArtifact artifact = session.resolveDirectMavenArtifact("org.bar", "bar", null, null, "1.0.0.Final"); diff --git a/core/src/test/java/org/wildfly/channel/ChannelWithRequirementsTestCase.java b/core/src/test/java/org/wildfly/channel/ChannelWithRequirementsTestCase.java index 0c430768..bd48ac12 100644 --- a/core/src/test/java/org/wildfly/channel/ChannelWithRequirementsTestCase.java +++ b/core/src/test/java/org/wildfly/channel/ChannelWithRequirementsTestCase.java @@ -66,7 +66,7 @@ public void testChannelWhichRequiresAnotherChannel() throws UnresolvedMavenArtif assertEquals(1, channels.size()); try (ChannelSession session = new ChannelSession(channels, factory)) { - MavenArtifact artifact = session.resolveMavenArtifact("org.example", "foo-bar", null, null); + MavenArtifact artifact = session.resolveMavenArtifact("org.example", "foo-bar", null, null, "0"); assertNotNull(artifact); assertEquals("org.example", artifact.getGroupId()); @@ -105,7 +105,7 @@ public void testChannelWhichRequiresAnotherVersionedChannel() throws UnresolvedM assertEquals(1, channels.size()); try (ChannelSession session = new ChannelSession(channels, factory)) { - MavenArtifact artifact = session.resolveMavenArtifact("org.example", "foo-bar", null, null); + MavenArtifact artifact = session.resolveMavenArtifact("org.example", "foo-bar", null, null, "0"); assertNotNull(artifact); assertEquals("org.example", artifact.getGroupId());