use of org.gradle.api.internal.tasks.compile.incremental.jar.JarChangeProcessor in project gradle by gradle.
the class RecompilationSpecProvider method provideRecompilationSpec.
public RecompilationSpec provideRecompilationSpec(IncrementalTaskInputs inputs, PreviousCompilation previousCompilation, JarClasspathSnapshot jarClasspathSnapshot) {
//creating an action that will be executed against all changes
RecompilationSpec spec = new RecompilationSpec();
JavaChangeProcessor javaChangeProcessor = new JavaChangeProcessor(previousCompilation, sourceToNameConverter);
ClassChangeProcessor classChangeProcessor = new ClassChangeProcessor(previousCompilation);
JarChangeProcessor jarChangeProcessor = new JarChangeProcessor(fileOperations, jarClasspathSnapshot, previousCompilation);
InputChangeAction action = new InputChangeAction(spec, javaChangeProcessor, classChangeProcessor, jarChangeProcessor);
//go!
inputs.outOfDate(action);
if (action.spec.getFullRebuildCause() != null) {
//short circuit in case we already know that that full rebuild is needed
return action.spec;
}
inputs.removed(action);
return action.spec;
}
use of org.gradle.api.internal.tasks.compile.incremental.jar.JarChangeProcessor 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