public static String findLatest(Collection<String> deploymentIds) { List<ComparableVersion> comparableVersions = new ArrayList<ComparableVersion>(); Map<String, String> versionToIdentifier = new HashMap<String, String>(); for (String deploymentId : deploymentIds) { GAVInfo gav = new GAVInfo(deploymentId); comparableVersions.add(new ComparableVersion(gav.getVersion())); versionToIdentifier.put(gav.getVersion(), deploymentId); } ComparableVersion latest = Collections.max(comparableVersions); return versionToIdentifier.get(latest.toString()); }
public static String matchAndReturnLatest( String deploymentId, Collection<String> availableDeployments) { try { GAVInfo gav = new GAVInfo(deploymentId); if (deploymentId != null && gav.getVersion().equalsIgnoreCase("latest")) { Collection<String> matched = matchDeployments(deploymentId, availableDeployments); if (matched != null && !matched.isEmpty()) { return findLatest(matched); } } } catch (Exception e) { logger.debug( "Unable to resolve latest version of deployment {} due to {}", deploymentId, e.getMessage()); } return deploymentId; }
private GroupAndArtifactMatchPredicate(String deploymentId) { this.gavInfo = new GAVInfo(deploymentId); this.groupArtifact = gavInfo.getGroupId() + ":" + gavInfo.getArtifactId(); }