use of org.gradle.scala.internal.reflect.ScalaOptionInvocationWrapper in project gradle by gradle.
the class TwirlCompiler method execute.
@Override
public WorkResult execute(TwirlCompileSpec spec) {
List<File> outputFiles = Lists.newArrayList();
ClassLoader cl = getClass().getClassLoader();
ScalaMethod compile = getCompileMethod(cl);
Iterable<RelativeFile> sources = spec.getSources();
for (RelativeFile sourceFile : sources) {
TwirlTemplateFormat format = findTemplateFormat(spec, sourceFile.getFile());
try {
Object result = compile.invoke(buildCompileArguments(spec, cl, sourceFile, format));
ScalaOptionInvocationWrapper<File> maybeFile = new ScalaOptionInvocationWrapper<File>(result);
if (maybeFile.isDefined()) {
File outputFile = maybeFile.get();
outputFiles.add(outputFile);
}
} catch (Exception e) {
throw new RuntimeException("Error invoking Play Twirl template compiler.", e);
}
}
return WorkResults.didWork(!outputFiles.isEmpty());
}
Aggregations