use of org.gradle.api.Transformer in project gradle by gradle.
the class HtmlDependencyReporter method render.
@Override
public void render(final Set<Project> projects, File outputDirectory) {
this.outputDirectory = outputDirectory;
HtmlReportRenderer renderer = new HtmlReportRenderer();
renderer.render(projects, new ReportRenderer<Set<Project>, HtmlReportBuilder>() {
@Override
public void render(Set<Project> model, HtmlReportBuilder builder) {
Transformer<String, Project> htmlPageScheme = projectNamingScheme("html");
Transformer<String, Project> jsScheme = projectNamingScheme("js");
ProjectPageRenderer projectPageRenderer = new ProjectPageRenderer(jsScheme);
builder.renderRawHtmlPage("index.html", projects, new ProjectsPageRenderer(htmlPageScheme));
for (Project project : projects) {
String jsFileName = jsScheme.transform(project);
generateJsFile(project, jsFileName);
String htmlFileName = htmlPageScheme.transform(project);
builder.renderRawHtmlPage(htmlFileName, project, projectPageRenderer);
}
}
}, outputDirectory);
}
use of org.gradle.api.Transformer in project gradle by gradle.
the class NativeSpecVisualStudioTargetBinary method getHeaderFiles.
@Override
public FileCollection getHeaderFiles() {
Spec<LanguageSourceSet> filter = new Spec<LanguageSourceSet>() {
@Override
public boolean isSatisfiedBy(LanguageSourceSet sourceSet) {
return sourceSet instanceof HeaderExportingSourceSet;
}
};
Transformer<FileCollection, LanguageSourceSet> transform = new Transformer<FileCollection, LanguageSourceSet>() {
@Override
public FileCollection transform(LanguageSourceSet sourceSet) {
HeaderExportingSourceSet exportingSourceSet = (HeaderExportingSourceSet) sourceSet;
return exportingSourceSet.getExportedHeaders().plus(exportingSourceSet.getImplicitHeaders());
}
};
return new LanguageSourceSetCollectionAdapter(getComponentName() + " header files", binary.getInputs(), filter, transform);
}
use of org.gradle.api.Transformer in project gradle by gradle.
the class ArgWriter method argsFileGenerator.
/**
* Returns an args transformer that replaces the provided args with a generated args file containing the args. Uses platform text encoding.
*/
public static Transformer<List<String>, List<String>> argsFileGenerator(final File argsFile, final Transformer<ArgWriter, PrintWriter> argWriterFactory) {
return new Transformer<List<String>, List<String>>() {
@Override
public List<String> transform(List<String> args) {
if (args.isEmpty()) {
return args;
}
argsFile.getParentFile().mkdirs();
try {
PrintWriter writer = new PrintWriter(argsFile);
try {
ArgWriter argWriter = argWriterFactory.transform(writer);
argWriter.args(args);
} finally {
writer.close();
}
} catch (IOException e) {
throw new UncheckedIOException(String.format("Could not write options file '%s'.", argsFile.getAbsolutePath()), e);
}
return Collections.singletonList("@" + argsFile.getAbsolutePath());
}
};
}
Aggregations