diff --git a/maven-universe/src/main/java/org/jboss/galleon/universe/maven/MavenChannel.java b/maven-universe/src/main/java/org/jboss/galleon/universe/maven/MavenChannel.java index 8808a8add..a3c1a6f26 100644 --- a/maven-universe/src/main/java/org/jboss/galleon/universe/maven/MavenChannel.java +++ b/maven-universe/src/main/java/org/jboss/galleon/universe/maven/MavenChannel.java @@ -105,7 +105,7 @@ public List getAllBuilds(FeaturePackLocation fpl) throws ProvisioningExc } @Override - public Path resolve(FeaturePackLocation fpl) throws MavenUniverseException { + public Path resolve(FeaturePackLocation fpl) throws ProvisioningException { final MavenArtifact artifact = new MavenArtifact(); artifact.setGroupId(producer.getFeaturePackGroupId()); artifact.setArtifactId(producer.getFeaturePackArtifactId()); @@ -115,7 +115,22 @@ public Path resolve(FeaturePackLocation fpl) throws MavenUniverseException { artifact.setVersionRange(versionRange); producer.getRepo().resolveLatestVersion(artifact, getFrequency(fpl), versionIncludePattern, versionExcludePattern); } else { - artifact.setVersion(fpl.getBuild()); + String build = fpl.getBuild(); + + // Make sure this build conforms to the specification of this Channel. + // Iterating a list isn't great but MavenRepoManager provides a list and other callers of + // getAllVersions request a list so converting to a Set would require care + // Iterate from the end of the list under the assumption that older versions less likely to be requested + boolean valid = false; + List allBuilds = getAllBuilds(fpl); + for (int i = allBuilds.size() - 1; !valid && i >= 0; i--) { + valid = build.equals(allBuilds.get(i)); + } + if (!valid) { + throw new MavenUniverseException(String.format("%s is not a valid build for channel %s", build, name)); + } + + artifact.setVersion(build); producer.getRepo().resolve(artifact); } return artifact.getPath(); diff --git a/maven-universe/src/main/java/org/jboss/galleon/universe/maven/repo/SimplisticMavenRepoManager.java b/maven-universe/src/main/java/org/jboss/galleon/universe/maven/repo/SimplisticMavenRepoManager.java index e0b95d508..4944aa954 100644 --- a/maven-universe/src/main/java/org/jboss/galleon/universe/maven/repo/SimplisticMavenRepoManager.java +++ b/maven-universe/src/main/java/org/jboss/galleon/universe/maven/repo/SimplisticMavenRepoManager.java @@ -20,6 +20,8 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.regex.Pattern; @@ -201,11 +203,21 @@ public String getLatestVersion(MavenArtifact artifact) throws MavenUniverseExcep @Override public List getAllVersions(MavenArtifact artifact) throws MavenUniverseException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return getAllVersions(artifact, null, null); } @Override public List getAllVersions(MavenArtifact artifact, Pattern includeVersion, Pattern excludeVersion) throws MavenUniverseException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + if(artifact.getGroupId() == null) { + MavenErrors.missingGroupId(); + } + Path p = repoHome; + final String[] groupParts = artifact.getGroupId().split("\\."); + for (String part : groupParts) { + p = p.resolve(part); + } + + String[] children = p.resolve(artifact.getArtifactId()).toFile().list(); + return children == null ? Collections.emptyList() : Arrays.asList(children); } }