}
public WorkResult execute(JavaCompileSpec spec) {
Clock clock = new Clock();
JarClasspathSnapshot jarClasspathSnapshot = jarClasspathSnapshotProvider.getJarClasspathSnapshot(spec.getClasspath());
RecompilationSpec recompilationSpec = recompilationSpecProvider.provideRecompilationSpec(inputs, previousCompilation, jarClasspathSnapshot);
if (recompilationSpec.isFullRebuildNeeded()) {
LOG.lifecycle("Full recompilation is required because {}. Analysis took {}.", recompilationSpec.getFullRebuildCause(), clock.getTime());
return cleaningCompiler.execute(spec);
}
incrementalCompilationInitilizer.initializeCompilation(spec, recompilationSpec.getClassNames());
if (spec.getSource().isEmpty()) {
LOG.lifecycle("None of the classes needs to compiled! Analysis took {}. ", clock.getTime());
return new RecompilationNotNecessary();
}
try {
//use the original compiler to avoid cleaning up all the files
return cleaningCompiler.getCompiler().execute(spec);
} finally {
LOG.lifecycle("Incremental compilation of {} classes completed in {}.", recompilationSpec.getClassNames().size(), clock.getTime());
}
}