Search in sources :

Example 6 with ArtifactDelta

use of org.eclipse.tycho.artifactcomparator.ArtifactDelta in project tycho by eclipse.

the class ManifestComparator method getDelta.

@Override
public ArtifactDelta getDelta(InputStream baseline, InputStream reactor, MojoExecution mojo) throws IOException {
    TreeMap<String, ArtifactDelta> result = new TreeMap<>();
    Manifest manifest = new Manifest(baseline);
    Manifest manifest2 = new Manifest(reactor);
    Attributes attributes = manifest.getMainAttributes();
    Attributes attributes2 = manifest2.getMainAttributes();
    Set<Name> names = new LinkedHashSet<>();
    names.addAll(getNames(attributes));
    names.addAll(getNames(attributes2));
    for (Name key : names) {
        String value = attributes.getValue(key);
        if (value == null) {
            addDelta(result, key, "not present in baseline version");
            continue;
        }
        String value2 = attributes2.getValue(key);
        if (value2 == null) {
            addDelta(result, key, "present in baseline version only");
            continue;
        }
        if (!value.equals(value2)) {
            addDelta(result, key, "baseline='" + value + "' != reactor='" + value2 + "'");
        }
    }
    return !result.isEmpty() ? new CompoundArtifactDelta("different", result) : null;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Attributes(java.util.jar.Attributes) ArtifactDelta(org.eclipse.tycho.artifactcomparator.ArtifactDelta) TreeMap(java.util.TreeMap) Manifest(java.util.jar.Manifest) Name(java.util.jar.Attributes.Name)

Aggregations

ArtifactDelta (org.eclipse.tycho.artifactcomparator.ArtifactDelta)6 LinkedHashMap (java.util.LinkedHashMap)3 TreeMap (java.util.TreeMap)3 CompoundArtifactDelta (org.eclipse.tycho.zipcomparator.internal.CompoundArtifactDelta)3 SimpleArtifactDelta (org.eclipse.tycho.zipcomparator.internal.SimpleArtifactDelta)3 IOException (java.io.IOException)2 LinkedHashSet (java.util.LinkedHashSet)2 IP2Artifact (org.eclipse.tycho.p2.metadata.IP2Artifact)2 File (java.io.File)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Properties (java.util.Properties)1 TreeSet (java.util.TreeSet)1 Attributes (java.util.jar.Attributes)1 Name (java.util.jar.Attributes.Name)1 Manifest (java.util.jar.Manifest)1 ZipEntry (java.util.zip.ZipEntry)1 ZipFile (java.util.zip.ZipFile)1