use of org.gradle.api.internal.tasks.compile.incremental.deps.AffectedClasses in project gradle by gradle.
the class JarChangeDependentsFinder method getActualDependents.
public DependentsSet getActualDependents(InputFileDetails jarChangeDetails, JarArchive jarArchive) {
if (jarChangeDetails.isAdded()) {
if (jarClasspathSnapshot.isAnyClassDuplicated(jarArchive)) {
// to avoid calculation which class gets on the classpath first, rebuild all
return DependentsSet.dependencyToAll("at least one of the classes of '" + jarArchive.file.getName() + "' is already present in classpath");
} else {
// none of the new classes in the jar are duplicated on classpath, don't rebuild
return DependentsSet.empty();
}
}
final JarSnapshot previous = previousCompilation.getJarSnapshot(jarChangeDetails.getFile());
if (previous == null) {
// for example, a class (in jar) with a constant might have changed into a class without a constant - we need to rebuild everything
return DependentsSet.dependencyToAll("missing jar snapshot of '" + jarArchive.file.getName() + "' from previous build");
}
if (jarChangeDetails.isRemoved()) {
DependentsSet allClasses = previous.getAllClasses();
if (allClasses.isDependencyToAll()) {
return DependentsSet.dependencyToAll("at least one of the classes of removed jar '" + jarArchive.file.getName() + "' requires it");
}
// recompile all dependents of all the classes from jar
return previousCompilation.getDependents(allClasses.getDependentClasses(), previous.getAllConstants(allClasses));
}
if (jarChangeDetails.isModified()) {
final JarSnapshot currentSnapshot = jarClasspathSnapshot.getSnapshot(jarArchive);
AffectedClasses affected = currentSnapshot.getAffectedClassesSince(previous);
DependentsSet altered = affected.getAltered();
if (altered.isDependencyToAll()) {
// at least one of the classes changed in the jar is a 'dependency-to-all'
return altered;
}
if (jarClasspathSnapshot.isAnyClassDuplicated(affected.getAdded())) {
// For safe measure rebuild everything
return DependentsSet.dependencyToAll("at least one of the classes of modified jar '" + jarArchive.file.getName() + "' is already present in the classpath");
}
// recompile all dependents of the classes changed in the jar
final Set<String> dependentClasses = Sets.newHashSet(altered.getDependentClasses());
final Deque<String> queue = Lists.newLinkedList(dependentClasses);
while (!queue.isEmpty()) {
final String dependentClass = queue.poll();
jarClasspathSnapshot.forEachSnapshot(new Action<JarSnapshot>() {
@Override
public void execute(JarSnapshot jarSnapshot) {
if (jarSnapshot != previous) {
// we need to find in the other jars classes that would potentially extend classes changed
// in the current snapshot (they are intermediates)
ClassSetAnalysisData data = jarSnapshot.getData().data;
Set<String> children = data.getChildren(dependentClass);
for (String child : children) {
if (dependentClasses.add(child)) {
queue.add(child);
}
}
}
}
});
}
return previousCompilation.getDependents(dependentClasses, currentSnapshot.getRelevantConstants(previous, dependentClasses));
}
throw new IllegalArgumentException("Unknown input file details provided: " + jarChangeDetails);
}
use of org.gradle.api.internal.tasks.compile.incremental.deps.AffectedClasses in project gradle by gradle.
the class JarSnapshot method getAffectedClassesSince.
public AffectedClasses getAffectedClassesSince(JarSnapshot other) {
DependentsSet affectedClasses = affectedSince(other);
Set<String> addedClasses = addedSince(other);
return new AffectedClasses(affectedClasses, addedClasses);
}
Aggregations