VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest);
List<Version> versions = Lists.reverse(rangeResult.getVersions());
// Version matchedVersion = rangeRequest.;
Version matchedVersion = null;
if (!snapshots) {
for (Version version : versions) {
if (!version.toString().toUpperCase().contains("SNAPSHOT")) {
matchedVersion = version;
break;
}
}
if (matchedVersion == null) {
matchedVersion = rangeResult.getHighestVersion();
if (matchedVersion != null) {
getLog().warn("didn't find non-snapshot version for " + artifactName +
", using snapshot version: " + matchedVersion);
}
}
} else {
matchedVersion = rangeResult.getHighestVersion();
}
if (matchedVersion == null) {
throw new MojoFailureException("didn't find matching version for " + artifactName);
}
artifactVersion = matchedVersion.toString();
getLog().info("found the latest version for " + artifact +": " + artifactVersion);
}
artifactName += ":" + artifactVersion;