use of org.eclipse.tycho.zipcomparator.internal.SimpleArtifactDelta in project tycho by eclipse.
the class CompoundArtifactDeltaTest method testGetDetailedMessage.
@Test
public void testGetDetailedMessage() {
Map<String, ArtifactDelta> manifest = new TreeMap<>();
manifest.put("name1", new SimpleArtifactDelta("present in baseline only"));
Map<String, ArtifactDelta> main = new TreeMap<>();
main.put("path/file1", new SimpleArtifactDelta("different"));
main.put("path/file2", new SimpleArtifactDelta("not present in baseline"));
main.put("META-INF/MANIFEST.MF", new CompoundArtifactDelta("different", manifest));
Map<String, ArtifactDelta> delta = new TreeMap<>();
delta.put("<main>", new CompoundArtifactDelta("different", main));
delta.put("sources", new SimpleArtifactDelta("different"));
ArtifactDelta subject = new CompoundArtifactDelta("Baseline and reactor artifacts have the same version but different contents", delta);
String expected = //
"Baseline and reactor artifacts have the same version but different contents\n" + //
" <main>: different\n" + //
" META-INF/MANIFEST.MF: different\n" + //
" name1: present in baseline only\n" + //
" path/file1: different\n" + //
" path/file2: not present in baseline\n" + " sources: different\n";
Assert.assertEquals(expected, subject.getDetailedMessage());
}
use of org.eclipse.tycho.zipcomparator.internal.SimpleArtifactDelta in project tycho by eclipse.
the class BaselineValidator method getDelta.
private CompoundArtifactDelta getDelta(BaselineService baselineService, Map<String, IP2Artifact> baselineMetadata, Map<String, IP2Artifact> generatedMetadata, MojoExecution execution) throws IOException {
Map<String, ArtifactDelta> result = new LinkedHashMap<>();
// baseline never includes more artifacts
for (Entry<String, IP2Artifact> classifierEntry : generatedMetadata.entrySet()) {
// the following types of artifacts are produced/consumed by tycho as of 0.16
// - bundle jar and jar.pack.gz artifacts
// - feature jar artifacts
// - feature rootfiles zip artifacts
String classifier = classifierEntry.getKey();
if (RepositoryLayoutHelper.PACK200_CLASSIFIER.equals(classifier)) {
// but bundle jar files are the same, the build will silently use baseline pack200 file
continue;
}
String deltaKey = classifier != null ? "classifier-" + classifier : "no-classifier";
IP2Artifact baselineArtifact = baselineMetadata.get(classifier);
IP2Artifact reactorArtifact = classifierEntry.getValue();
if (baselineArtifact == null) {
result.put(deltaKey, new MissingArtifactDelta());
continue;
}
if (!baselineService.isMetadataEqual(baselineArtifact, reactorArtifact)) {
result.put(deltaKey, new SimpleArtifactDelta("p2 metadata different"));
continue;
}
try {
ArtifactDelta delta = zipComparator.getDelta(baselineArtifact.getLocation(), reactorArtifact.getLocation(), execution);
if (delta != null) {
result.put(deltaKey, delta);
}
} catch (IOException e) {
// do byte-to-byte comparison if jar comparison fails for whatever reason
if (!FileUtils.contentEquals(baselineArtifact.getLocation(), reactorArtifact.getLocation())) {
result.put(deltaKey, new SimpleArtifactDelta("different"));
}
}
}
return !result.isEmpty() ? new CompoundArtifactDelta("baseline and build artifacts have same version but different contents", result) : null;
}
Aggregations