Search in sources :

Example 1 with RecompilationSpec

use of org.gradle.api.internal.tasks.compile.incremental.recomp.RecompilationSpec 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;
}
Also used : RecompilationSpec(org.gradle.api.internal.tasks.compile.incremental.recomp.RecompilationSpec) JarChangeProcessor(org.gradle.api.internal.tasks.compile.incremental.jar.JarChangeProcessor)

Example 2 with RecompilationSpec

use of org.gradle.api.internal.tasks.compile.incremental.recomp.RecompilationSpec in project gradle by gradle.

the class RecompilationSpecProvider method provideRecompilationSpec.

public RecompilationSpec provideRecompilationSpec(CurrentCompilation current, PreviousCompilation previous) {
    RecompilationSpec spec = new RecompilationSpec();
    processJarClasspathChanges(current, previous, spec);
    processOtherChanges(current, previous, spec);
    spec.getClassesToProcess().addAll(previous.getAggregatedTypes().getDependentClasses());
    return spec;
}
Also used : RecompilationSpec(org.gradle.api.internal.tasks.compile.incremental.recomp.RecompilationSpec)

Example 3 with RecompilationSpec

use of org.gradle.api.internal.tasks.compile.incremental.recomp.RecompilationSpec in project gradle by gradle.

the class SelectiveCompiler method execute.

@Override
public WorkResult execute(JavaCompileSpec spec) {
    Timer clock = Time.startTimer();
    CurrentCompilation currentCompilation = new CurrentCompilation(inputs, spec, jarClasspathSnapshotProvider);
    RecompilationSpec recompilationSpec = recompilationSpecProvider.provideRecompilationSpec(currentCompilation, previousCompilation);
    if (recompilationSpec.isFullRebuildNeeded()) {
        LOG.info("Full recompilation is required because {}. Analysis took {}.", recompilationSpec.getFullRebuildCause(), clock.getElapsed());
        return cleaningCompiler.execute(spec);
    }
    incrementalCompilationInitilizer.initializeCompilation(spec, recompilationSpec);
    if (spec.getSource().isEmpty() && spec.getClasses().isEmpty()) {
        LOG.info("None of the classes needs to be compiled! Analysis took {}. ", clock.getElapsed());
        return new RecompilationNotNecessary();
    }
    try {
        return cleaningCompiler.getCompiler().execute(spec);
    } finally {
        Collection<String> classesToCompile = recompilationSpec.getClassesToCompile();
        LOG.info("Incremental compilation of {} classes completed in {}.", classesToCompile.size(), clock.getElapsed());
        LOG.debug("Recompiled classes {}", classesToCompile);
    }
}
Also used : RecompilationSpec(org.gradle.api.internal.tasks.compile.incremental.recomp.RecompilationSpec) Timer(org.gradle.internal.time.Timer)

Aggregations

RecompilationSpec (org.gradle.api.internal.tasks.compile.incremental.recomp.RecompilationSpec)3 JarChangeProcessor (org.gradle.api.internal.tasks.compile.incremental.jar.JarChangeProcessor)1 Timer (org.gradle.internal.time.Timer)1