use of org.gradle.api.internal.file.RelativeFile in project gradle by gradle.
the class SerializableCoffeeScriptCompileSpec method toRelativeFiles.
public static void toRelativeFiles(final FileCollection source, final List<RelativeFile> targets) {
FileTree fileTree = source.getAsFileTree();
fileTree.visit(new FileVisitor() {
public void visitDir(FileVisitDetails dirDetails) {
}
public void visitFile(FileVisitDetails fileDetails) {
targets.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
}
});
}
use of org.gradle.api.internal.file.RelativeFile in project gradle by gradle.
the class GoogleClosureCompiler method execute.
@Override
public WorkResult execute(JavaScriptCompileSpec spec) {
JavaScriptCompileDestinationCalculator destinationCalculator = new JavaScriptCompileDestinationCalculator(spec.getDestinationDir());
List<String> allErrors = Lists.newArrayList();
for (RelativeFile sourceFile : spec.getSources()) {
allErrors.addAll(compile(sourceFile, spec, destinationCalculator));
}
if (allErrors.isEmpty()) {
return WorkResults.didWork(true);
} else {
throw new SourceTransformationException(String.format("Minification failed with the following errors:\n\t%s", StringUtils.join(allErrors, "\n\t")), null);
}
}
use of org.gradle.api.internal.file.RelativeFile in project gradle by gradle.
the class CoffeeScriptCompilerWorker method process.
public void process(SerializableCoffeeScriptCompileSpec spec) {
Scriptable coffeeScriptScope = parse(spec.getCoffeeScriptJs(), "UTF-8", new Action<Context>() {
public void execute(Context context) {
context.setOptimizationLevel(-1);
}
});
String encoding = spec.getOptions().getEncoding();
CoffeeScriptCompileDestinationCalculator destinationCalculator = new CoffeeScriptCompileDestinationCalculator(spec.getDestinationDir());
for (RelativeFile target : spec.getSource()) {
String source = readFile(target.getFile(), encoding);
String output = compile(coffeeScriptScope, source, target.getRelativePath().getPathString());
writeFile(output, destinationCalculator.transform(target.getRelativePath()), encoding);
}
}
use of org.gradle.api.internal.file.RelativeFile 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