Java Code Examples for org.gradle.api.tasks.incremental.InputFileDetails#isAdded()

The following examples show how to use org.gradle.api.tasks.incremental.InputFileDetails#isAdded() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JarChangeProcessor.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public RebuildInfo processJarChange(InputFileDetails jarChangeDetails, JarArchive jarArchive) {
    JarSnapshot existing = jarSnapshotFeeder.changedJar(jarChangeDetails.getFile());
    if (jarChangeDetails.isAdded()) {
        return DefaultRebuildInfo.NOTHING_TO_REBUILD;
    }

    if (jarChangeDetails.isRemoved()) {
        if (existing != null) {
            return new AllFromJarRebuildInfo(jarArchive);
        } else {
            return DefaultRebuildInfo.FULL_REBUILD;
        }
    }

    if (jarChangeDetails.isModified()) {
        if (existing != null) {
            JarSnapshot newSnapshot = jarSnapshotFeeder.createSnapshot(jarArchive);
            JarDelta jarDelta = existing.compareToSnapshot(newSnapshot);
            return new SpecificClassesRebuildInfo(jarDelta);
        } else {
            return new AllFromJarRebuildInfo(jarArchive);
        }
    }

    throw new IllegalArgumentException("Unknown input file details provided: " + jarChangeDetails);
}
 
Example 2
Source File: JarChangeProcessor.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public RebuildInfo processJarChange(InputFileDetails jarChangeDetails, JarArchive jarArchive) {
    JarSnapshot existing = jarSnapshotFeeder.changedJar(jarChangeDetails.getFile());
    if (jarChangeDetails.isAdded()) {
        return DefaultRebuildInfo.NOTHING_TO_REBUILD;
    }

    if (jarChangeDetails.isRemoved()) {
        if (existing != null) {
            return new AllFromJarRebuildInfo(jarArchive);
        } else {
            return DefaultRebuildInfo.FULL_REBUILD;
        }
    }

    if (jarChangeDetails.isModified()) {
        if (existing != null) {
            JarSnapshot newSnapshot = jarSnapshotFeeder.createSnapshot(jarArchive);
            JarDelta jarDelta = existing.compareToSnapshot(newSnapshot);
            return new SpecificClassesRebuildInfo(jarDelta);
        } else {
            return new AllFromJarRebuildInfo(jarArchive);
        }
    }

    throw new IllegalArgumentException("Unknown input file details provided: " + jarChangeDetails);
}
 
Example 3
Source File: JarChangeDependentsFinder.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DependentsSet getActualDependents(InputFileDetails jarChangeDetails, JarArchive jarArchive) {
    if (jarChangeDetails.isAdded()) {
        if (jarClasspathSnapshot.isAnyClassDuplicated(jarArchive)) {
            //at least one of the classes from the new jar is already present in jar classpath
            //to avoid calculation which class gets on the classpath first, rebuild all
            return new 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 new DefaultDependentsSet();
        }
    }
    JarSnapshot previous = previousCompilation.getJarSnapshot(jarChangeDetails.getFile());

    if (previous == null) {
        //we don't know what classes were dependents of the jar in the previous build
        //for example, a class (in jar) with a constant might have changed into a class without a constant - we need to rebuild everything
        return new DependencyToAll("missing jar snapshot of '" + jarArchive.file.getName()  + "' from previous build");
    }

    if (jarChangeDetails.isRemoved()) {
        DependentsSet allClasses = previous.getAllClasses();
        if (allClasses.isDependencyToAll()) {
            return new 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());
    }

    if (jarChangeDetails.isModified()) {
        JarSnapshot currentSnapshot = jarClasspathSnapshot.getSnapshot(jarArchive);
        AffectedClasses affected = currentSnapshot.getAffectedClassesSince(previous);
        if (affected.getAltered().isDependencyToAll()) {
            //at least one of the classes changed in the jar is a 'dependency-to-all'
            return affected.getAltered();
        }

        if (jarClasspathSnapshot.isAnyClassDuplicated(affected.getAdded())) {
            //A new duplicate class on classpath. As we don't fancy-handle classpath order right now, we don't know which class is on classpath first.
            //For safe measure rebuild everything
            return new 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
        return previousCompilation.getDependents(affected.getAltered().getDependentClasses());
    }

    throw new IllegalArgumentException("Unknown input file details provided: " + jarChangeDetails);
}
 
Example 4
Source File: JarChangeDependentsFinder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DependentsSet getActualDependents(InputFileDetails jarChangeDetails, JarArchive jarArchive) {
    if (jarChangeDetails.isAdded()) {
        if (jarClasspathSnapshot.isAnyClassDuplicated(jarArchive)) {
            //at least one of the classes from the new jar is already present in jar classpath
            //to avoid calculation which class gets on the classpath first, rebuild all
            return new 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 new DefaultDependentsSet();
        }
    }
    JarSnapshot previous = previousCompilation.getJarSnapshot(jarChangeDetails.getFile());

    if (previous == null) {
        //we don't know what classes were dependents of the jar in the previous build
        //for example, a class (in jar) with a constant might have changed into a class without a constant - we need to rebuild everything
        return new DependencyToAll("missing jar snapshot of '" + jarArchive.file.getName()  + "' from previous build");
    }

    if (jarChangeDetails.isRemoved()) {
        DependentsSet allClasses = previous.getAllClasses();
        if (allClasses.isDependencyToAll()) {
            return new 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());
    }

    if (jarChangeDetails.isModified()) {
        JarSnapshot currentSnapshot = jarClasspathSnapshot.getSnapshot(jarArchive);
        AffectedClasses affected = currentSnapshot.getAffectedClassesSince(previous);
        if (affected.getAltered().isDependencyToAll()) {
            //at least one of the classes changed in the jar is a 'dependency-to-all'
            return affected.getAltered();
        }

        if (jarClasspathSnapshot.isAnyClassDuplicated(affected.getAdded())) {
            //A new duplicate class on classpath. As we don't fancy-handle classpath order right now, we don't know which class is on classpath first.
            //For safe measure rebuild everything
            return new 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
        return previousCompilation.getDependents(affected.getAltered().getDependentClasses());
    }

    throw new IllegalArgumentException("Unknown input file details provided: " + jarChangeDetails);
}