@TaskAction
void compile(IncrementalTaskInputs inputs) {
String compilerVersion = detectCompilerVersion();
if (!inputs.isIncremental()) {
TwirlCompileSpec spec = generateSpec(getSource().getFiles(), compilerVersion);
if(compiler==null){
compiler = new CleaningPlayToolCompiler<TwirlCompileSpec>(getCompiler(spec), getOutputs());
}
compiler.execute(spec);
} else {
final Set<File> sourcesToCompile = new HashSet<File>();
inputs.outOfDate(new Action<InputFileDetails>() {
public void execute(InputFileDetails inputFileDetails) {
sourcesToCompile.add(inputFileDetails.getFile());
}
});
final Set<File> staleOutputFiles = new HashSet<File>();
inputs.removed(new Action<InputFileDetails>() {
public void execute(InputFileDetails inputFileDetails) {
staleOutputFiles.add(inputFileDetails.getFile());
}
});
if (cleaner == null) {
cleaner = new TwirlStaleOutputCleaner(getOutputDirectory());
}
cleaner.execute(staleOutputFiles);
TwirlCompileSpec spec = generateSpec(sourcesToCompile, compilerVersion);
getCompiler(spec).execute(spec);
}
}