use of org.gradle.api.internal.tasks.compile.incremental.recomp.CurrentCompilation in project gradle by gradle.
the class SelectiveCompiler method execute.
@Override
public WorkResult execute(T spec) {
if (!recompilationSpecProvider.isIncremental()) {
LOG.info("Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.");
return rebuildAllCompiler.execute(spec);
}
File previousCompilationDataFile = Objects.requireNonNull(spec.getCompileOptions().getPreviousCompilationDataFile());
if (!previousCompilationDataFile.exists()) {
LOG.info("Full recompilation is required because no previous compilation result is available.");
return rebuildAllCompiler.execute(spec);
}
if (spec.getSourceRoots().isEmpty()) {
LOG.info("Full recompilation is required because the source roots could not be inferred.");
return rebuildAllCompiler.execute(spec);
}
Timer clock = Time.startTimer();
CurrentCompilation currentCompilation = new CurrentCompilation(spec, classpathSnapshotter);
PreviousCompilationData previousCompilationData = previousCompilationAccess.readPreviousCompilationData(previousCompilationDataFile);
PreviousCompilation previousCompilation = new PreviousCompilation(previousCompilationData);
RecompilationSpec recompilationSpec = recompilationSpecProvider.provideRecompilationSpec(currentCompilation, previousCompilation);
if (recompilationSpec.isFullRebuildNeeded()) {
LOG.info("Full recompilation is required because {}. Analysis took {}.", recompilationSpec.getFullRebuildCause(), clock.getElapsed());
return rebuildAllCompiler.execute(spec);
}
boolean cleanedOutput = recompilationSpecProvider.initializeCompilation(spec, recompilationSpec);
if (Iterables.isEmpty(spec.getSourceFiles()) && spec.getClasses().isEmpty()) {
LOG.info("None of the classes needs to be compiled! Analysis took {}. ", clock.getElapsed());
return new RecompilationNotNecessary(previousCompilationData, recompilationSpec);
}
try {
WorkResult result = recompilationSpecProvider.decorateResult(recompilationSpec, previousCompilationData, cleaningCompiler.getCompiler().execute(spec));
return result.or(WorkResults.didWork(cleanedOutput));
} finally {
Collection<String> classesToCompile = recompilationSpec.getClassesToCompile();
LOG.info("Incremental compilation of {} classes completed in {}.", classesToCompile.size(), clock.getElapsed());
LOG.debug("Recompiled classes {}", classesToCompile);
}
}
Aggregations