Search in sources :

Example 1 with ArtifactVersions

use of org.codehaus.mojo.versions.api.ArtifactVersions in project sling by apache.

the class DisplayBundleUpdatesMojo method logUpdates.

private void logUpdates(Map<Dependency, ArtifactVersions> updates) {
    List<String> withUpdates = new ArrayList<String>();
    List<String> usingCurrent = new ArrayList<String>();
    for (ArtifactVersions versions : updates.values()) {
        String left = "  " + ArtifactUtils.versionlessKey(versions.getArtifact()) + " ";
        final String current = versions.isCurrentVersionDefined() ? versions.getCurrentVersion().toString() : versions.getArtifact().getVersionRange().toString();
        ArtifactVersion latest = versions.getNewestUpdate(UpdateScope.ANY, Boolean.TRUE.equals(allowSnapshots));
        if (latest != null && !versions.isCurrentVersionDefined()) {
            if (versions.getArtifact().getVersionRange().containsVersion(latest)) {
                latest = null;
            }
        }
        String right = " " + (latest == null ? current : current + " -> " + latest.toString());
        List<String> t = latest == null ? usingCurrent : withUpdates;
        if (right.length() + left.length() + 3 > INFO_PAD_SIZE) {
            t.add(left + "...");
            t.add(StringUtils.leftPad(right, INFO_PAD_SIZE));
        } else {
            t.add(StringUtils.rightPad(left, INFO_PAD_SIZE - right.length(), ".") + right);
        }
    }
    if (usingCurrent.isEmpty() && !withUpdates.isEmpty()) {
        getLog().info("No bundles are using the newest version.");
        getLog().info("");
    } else if (!usingCurrent.isEmpty()) {
        getLog().info("The following bundles are using the newest version:");
        for (String str : usingCurrent) {
            getLog().info(str);
        }
        getLog().info("");
    }
    if (withUpdates.isEmpty() && !usingCurrent.isEmpty()) {
        getLog().info("No bundles have newer versions.");
        getLog().info("");
    } else if (!withUpdates.isEmpty()) {
        getLog().info("The following bundles have newer versions:");
        for (String str : withUpdates) {
            getLog().info(str);
        }
        getLog().info("");
    }
}
Also used : ArtifactVersions(org.codehaus.mojo.versions.api.ArtifactVersions) ArtifactVersion(org.apache.maven.artifact.versioning.ArtifactVersion) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 ArtifactVersion (org.apache.maven.artifact.versioning.ArtifactVersion)1 ArtifactVersions (org.codehaus.mojo.versions.api.ArtifactVersions)1