Skip to content

Commit

Permalink
[wildfly-extras#53] add baseVersion parameter to ChannelSession#resol…
Browse files Browse the repository at this point in the history
…veMavenArtifact

This fixes wildfly-extras#53

Signed-off-by: Jeff Mesnil <[email protected]>
  • Loading branch information
jmesnil committed Jun 1, 2022
1 parent 88e6cf1 commit 6735e43
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
9 changes: 8 additions & 1 deletion core/src/main/java/org/wildfly/channel/ChannelSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,10 +56,16 @@ public ChannelSession(List<Channel> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 6735e43

Please sign in to comment.