use of org.gradle.internal.util.Alignment in project gradle by gradle.
the class RecompilationSpecProvider method processJarClasspathChanges.
private void processJarClasspathChanges(CurrentCompilation current, PreviousCompilation previous, RecompilationSpec spec) {
JarChangeProcessor jarChangeProcessor = new JarChangeProcessor(fileOperations, current.getClasspathSnapshot(), previous);
Map<File, JarSnapshot> previousCompilationJarSnapshots = previous.getJarSnapshots();
JarClasspathSnapshot currentJarSnapshots = current.getClasspathSnapshot();
Set<File> previousCompilationJars = previousCompilationJarSnapshots.keySet();
Set<File> currentCompilationJars = currentJarSnapshots.getJars();
List<Alignment<File>> alignment = Alignment.align(currentCompilationJars.toArray(new File[0]), previousCompilationJars.toArray(new File[0]));
for (Alignment<File> fileAlignment : alignment) {
switch(fileAlignment.getKind()) {
case added:
jarChangeProcessor.processChange(FileChange.added(fileAlignment.getCurrentValue().getAbsolutePath(), "jar", FileType.RegularFile), spec);
break;
case removed:
jarChangeProcessor.processChange(FileChange.removed(fileAlignment.getPreviousValue().getAbsolutePath(), "jar", FileType.RegularFile), spec);
break;
case transformed:
// If we detect a transformation in the classpath, we need to recompile, because we could typically be facing the case where
// 2 jars are reversed in the order of classpath elements, and one class that was shadowing the other is now visible
spec.setFullRebuildCause("Classpath has been changed", null);
return;
case identical:
File key = fileAlignment.getPreviousValue();
JarSnapshot previousSnapshot = previousCompilationJarSnapshots.get(key);
JarSnapshot snapshot = currentJarSnapshots.getSnapshot(key);
if (!snapshot.getHash().equals(previousSnapshot.getHash())) {
jarChangeProcessor.processChange(FileChange.modified(key.getAbsolutePath(), "jar", FileType.RegularFile, FileType.RegularFile), spec);
}
break;
}
}
}
Aggregations