Java Code Examples for org.gradle.api.tasks.incremental.IncrementalTaskInputs#outOfDate()

The following examples show how to use org.gradle.api.tasks.incremental.IncrementalTaskInputs#outOfDate() . 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: RecompilationSpecProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
    JarChangeProcessor jarChangeProcessor = new JarChangeProcessor(fileOperations, jarClasspathSnapshot, previousCompilation);
    InputChangeAction action = new InputChangeAction(spec, javaChangeProcessor, 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;
}
 
Example 2
Source File: RecompilationSpecProvider.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
    JarChangeProcessor jarChangeProcessor = new JarChangeProcessor(fileOperations, jarClasspathSnapshot, previousCompilation);
    InputChangeAction action = new InputChangeAction(spec, javaChangeProcessor, 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;
}
 
Example 3
Source File: SelectiveCompilation.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public SelectiveCompilation(IncrementalTaskInputs inputs, FileTree source, FileCollection compileClasspath, final File compileDestination,
                            final ClassDependencyInfoSerializer dependencyInfoSerializer, final JarSnapshotCache jarSnapshotCache, final SelectiveJavaCompiler compiler,
                            Iterable<File> sourceDirs, final FileOperations operations) {
    this.operations = operations;
    this.jarSnapshotFeeder = new JarSnapshotFeeder(jarSnapshotCache, new JarSnapshotter(new DefaultHasher()));
    this.compiler = compiler;

    Clock clock = new Clock();
    final InputOutputMapper mapper = new InputOutputMapper(sourceDirs, compileDestination);

    //load dependency info
    final ClassDependencyInfo dependencyInfo = dependencyInfoSerializer.readInfo();

    //including only source java classes that were changed
    final PatternSet changedSourceOnly = new PatternSet();
    InputFileDetailsAction action = new InputFileDetailsAction(mapper, compiler, changedSourceOnly, dependencyInfo);
    inputs.outOfDate(action);
    inputs.removed(action);
    if (fullRebuildNeeded != null) {
        LOG.lifecycle("Stale classes detection completed in {}. Rebuild needed: {}.", clock.getTime(), fullRebuildNeeded);
        this.classpath = compileClasspath;
        this.source = source;
        return;
    }

    compiler.deleteStaleClasses();
    Set<File> filesToCompile = source.matching(changedSourceOnly).getFiles();
    if (filesToCompile.isEmpty()) {
        this.compilationNeeded = false;
        this.classpath = compileClasspath;
        this.source = source;
    } else {
        this.classpath = compileClasspath.plus(new SimpleFileCollection(compileDestination));
        this.source = source.matching(changedSourceOnly);
    }
    LOG.lifecycle("Stale classes detection completed in {}. Compile include patterns: {}.", clock.getTime(), changedSourceOnly.getIncludes());
}
 
Example 4
Source File: SelectiveCompilation.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public SelectiveCompilation(IncrementalTaskInputs inputs, FileTree source, FileCollection compileClasspath, final File compileDestination,
                            final ClassDependencyInfoSerializer dependencyInfoSerializer, final JarSnapshotCache jarSnapshotCache, final SelectiveJavaCompiler compiler,
                            Iterable<File> sourceDirs, final FileOperations operations) {
    this.operations = operations;
    this.jarSnapshotFeeder = new JarSnapshotFeeder(jarSnapshotCache, new JarSnapshotter(new DefaultHasher()));
    this.compiler = compiler;

    Clock clock = new Clock();
    final InputOutputMapper mapper = new InputOutputMapper(sourceDirs, compileDestination);

    //load dependency info
    final ClassDependencyInfo dependencyInfo = dependencyInfoSerializer.readInfo();

    //including only source java classes that were changed
    final PatternSet changedSourceOnly = new PatternSet();
    InputFileDetailsAction action = new InputFileDetailsAction(mapper, compiler, changedSourceOnly, dependencyInfo);
    inputs.outOfDate(action);
    inputs.removed(action);
    if (fullRebuildNeeded != null) {
        LOG.lifecycle("Stale classes detection completed in {}. Rebuild needed: {}.", clock.getTime(), fullRebuildNeeded);
        this.classpath = compileClasspath;
        this.source = source;
        return;
    }

    compiler.deleteStaleClasses();
    Set<File> filesToCompile = source.matching(changedSourceOnly).getFiles();
    if (filesToCompile.isEmpty()) {
        this.compilationNeeded = false;
        this.classpath = compileClasspath;
        this.source = source;
    } else {
        this.classpath = compileClasspath.plus(new SimpleFileCollection(compileDestination));
        this.source = source.matching(changedSourceOnly);
    }
    LOG.lifecycle("Stale classes detection completed in {}. Compile include patterns: {}.", clock.getTime(), changedSourceOnly.getIncludes());
}
 
Example 5
Source File: Dex.java    From atlas with Apache License 2.0 4 votes vote down vote up
/**
 * Actual entry point for the action.
 * Calls out to the doTaskAction as needed.
 */
@TaskAction
public void taskAction(IncrementalTaskInputs inputs) throws IOException, InterruptedException, ProcessException {
    Collection<File> _inputFiles = getInputFiles();
    File _inputDir = getInputDir();
    if (_inputFiles == null && _inputDir == null) {
        throw new RuntimeException("Dex task \'" + getName() + ": inputDir and inputFiles cannot both be null");
    }

    if (!dexOptions.getIncremental() || !enableIncremental) {
        doTaskAction(_inputFiles, _inputDir, false);
        return;

    }

    if (!inputs.isIncremental()) {
        getProject().getLogger().info("Unable to do incremental execution: full task run.");
        doTaskAction(_inputFiles, _inputDir, false);
        return;

    }

    final AtomicBoolean forceFullRun = new AtomicBoolean();

    //noinspection GroovyAssignabilityCheck
    inputs.outOfDate(new Action<InputFileDetails>() {
        @Override
        public void execute(InputFileDetails change) {
            // force full dx run if existing jar file is modified
            // New jar files are fine.
            if (((InputFileDetails)change).isModified() && ((InputFileDetails)change).getFile().getPath().endsWith(
                SdkConstants.DOT_JAR)) {
                getProject().getLogger().info(
                    "Force full dx run: Found updated " + String.valueOf(((InputFileDetails)change).getFile()));
                forceFullRun.set(true);
            }

        }

    });

    //noinspection GroovyAssignabilityCheck
    inputs.removed(change -> {
        // force full dx run if existing jar file is removed
        if (((InputFileDetails)change).getFile().getPath().endsWith(SdkConstants.DOT_JAR)) {
            getProject().getLogger().info(
                "Force full dx run: Found removed " + String.valueOf(((InputFileDetails)change).getFile()));
            forceFullRun.set(true);
        }

    });

    doTaskAction(_inputFiles, _inputDir, !forceFullRun.get());
}