Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public List<String> 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());
Expand All @@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we simply check whether the specified build matches the version patterns of this channel instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aloubyansky We could but that doesn't deal with the user providing a build that is outside the version range or frequency of the channel.


// 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<String> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -201,11 +203,21 @@ public String getLatestVersion(MavenArtifact artifact) throws MavenUniverseExcep

@Override
public List<String> 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<String> 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);
}
}