}
}
protected String getBestVersionForArtifact(Artifact artifact, List<ArtifactVersion> versions) throws ArtifactMetadataRetrievalException {
if (versions.size() == 0) {
throw new ArtifactMetadataRetrievalException("No wrapper bundle available for " + artifact);
}
Collections.sort(versions, Collections.reverseOrder());
//check for same version
for (ArtifactVersion version : versions) {
if (version.toString().startsWith(artifact.getVersion())) {
return version.toString();
}
}
//check for same major/minor version
for (ArtifactVersion version : versions) {
String[] elements = version.toString().split("\\.");
if (elements.length >= 2 && artifact.getVersion().startsWith(elements[0] + "." + elements[1])) {
return version.toString();
}
}
throw new ArtifactMetadataRetrievalException("No suitable version found for " + artifact + " wrapper bundle");
}