final VersionRangeRequest request = new VersionRangeRequest().setRepositories(repos).setArtifact(artifact);
final VersionRangeResult result = system.resolveVersionRange(session, request);
final Version highestVersion = result.getHighestVersion();
version = highestVersion != null ? highestVersion.toString() : null;
} else {
final VersionRequest request = new VersionRequest().setRepositories(repos).setArtifact(artifact);
final VersionResult result = system.resolveVersion(session, request);
version = result.getVersion();
}
if (version == null)
throw new RuntimeException("Could not find any version of artifact " + coords + " (looking for: " + artifact + ")");