use of com.google.cloud.tools.opensource.dependencies.VersionComparator in project java-cloud-bom by googleapis.
the class DashboardMain method generateAllVersions.
private static void generateAllVersions(String versionlessCoordinates) throws IOException, TemplateException, RepositoryException, URISyntaxException, MavenRepositoryException {
List<String> elements = Splitter.on(':').splitToList(versionlessCoordinates);
checkArgument(elements.size() == 2, "The versionless coordinates should have one colon character: " + versionlessCoordinates);
String groupId = elements.get(0);
String artifactId = elements.get(1);
RepositorySystem repositorySystem = RepositoryUtility.newRepositorySystem();
ImmutableList<String> versions = RepositoryUtility.findVersions(repositorySystem, groupId, artifactId);
for (String version : versions) {
if (version.contains("alpha")) {
continue;
}
bomVersions.add(version);
}
// Reverse the ordering, placing higher versions first
VersionComparator comparator = new VersionComparator();
Collections.sort(bomVersions, (b1, b2) -> comparator.compare(b2, b1));
bomVersions.add(VersionData.ALL_VERSIONS_NAME);
for (String version : bomVersions) {
// are used to collect data for the 'All Versions' page.
if (!VersionData.ALL_VERSIONS_NAME.equals(version)) {
generate(Bom.readBom(String.format("%s:%s:%s", groupId, artifactId, version)));
}
}
generateAllVersionsDashboard();
}
use of com.google.cloud.tools.opensource.dependencies.VersionComparator in project cloud-opensource-java by GoogleCloudPlatform.
the class DashboardMain method collectLatestVersions.
private static Map<String, String> collectLatestVersions(List<DependencyGraph> globalDependencies) {
Map<String, String> latestArtifacts = new TreeMap<>();
VersionComparator comparator = new VersionComparator();
if (globalDependencies != null) {
for (DependencyGraph graph : globalDependencies) {
Map<String, String> map = graph.getHighestVersionMap();
for (String key : map.keySet()) {
String newVersion = map.get(key);
String oldVersion = latestArtifacts.get(key);
if (oldVersion == null || comparator.compare(newVersion, oldVersion) > 0) {
latestArtifacts.put(key, map.get(key));
}
}
}
}
return latestArtifacts;
}
use of com.google.cloud.tools.opensource.dependencies.VersionComparator in project cloud-opensource-java by GoogleCloudPlatform.
the class DashboardMain method findUpperBoundsFailures.
private static Map<Artifact, Artifact> findUpperBoundsFailures(Map<String, String> expectedVersionMap, DependencyGraph transitiveDependencies) {
Map<String, String> actualVersionMap = transitiveDependencies.getHighestVersionMap();
VersionComparator comparator = new VersionComparator();
Map<Artifact, Artifact> upperBoundFailures = new LinkedHashMap<>();
for (String id : expectedVersionMap.keySet()) {
String expectedVersion = expectedVersionMap.get(id);
String actualVersion = actualVersionMap.get(id);
// In both cases, no action is needed.
if (actualVersion != null && comparator.compare(actualVersion, expectedVersion) < 0) {
// Maven did not choose highest version
DefaultArtifact lower = new DefaultArtifact(id + ":" + actualVersion);
DefaultArtifact upper = new DefaultArtifact(id + ":" + expectedVersion);
upperBoundFailures.put(lower, upper);
}
}
return upperBoundFailures;
}
use of com.google.cloud.tools.opensource.dependencies.VersionComparator in project java-cloud-bom by googleapis.
the class DashboardMain method findUpperBoundsFailures.
private static Map<Artifact, Artifact> findUpperBoundsFailures(Map<String, String> expectedVersionMap, DependencyGraph transitiveDependencies) {
Map<String, String> actualVersionMap = transitiveDependencies.getHighestVersionMap();
VersionComparator comparator = new VersionComparator();
Map<Artifact, Artifact> upperBoundFailures = new LinkedHashMap<>();
for (String id : expectedVersionMap.keySet()) {
String expectedVersion = expectedVersionMap.get(id);
String actualVersion = actualVersionMap.get(id);
// In both cases, no action is needed.
if (actualVersion != null && comparator.compare(actualVersion, expectedVersion) < 0) {
// Maven did not choose highest version
DefaultArtifact lower = new DefaultArtifact(id + ":" + actualVersion);
DefaultArtifact upper = new DefaultArtifact(id + ":" + expectedVersion);
upperBoundFailures.put(lower, upper);
}
}
return upperBoundFailures;
}
Aggregations