Search in sources :

Example 11 with Transformer

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);
}
Also used : Project(org.gradle.api.Project) Set(java.util.Set) HtmlReportBuilder(org.gradle.reporting.HtmlReportBuilder) Transformer(org.gradle.api.Transformer) HtmlReportRenderer(org.gradle.reporting.HtmlReportRenderer)

Example 12 with Transformer

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);
}
Also used : LanguageSourceSet(org.gradle.language.base.LanguageSourceSet) Transformer(org.gradle.api.Transformer) HeaderExportingSourceSet(org.gradle.language.nativeplatform.HeaderExportingSourceSet) SharedLibraryBinarySpec(org.gradle.nativeplatform.SharedLibraryBinarySpec) NativeTestSuiteBinarySpec(org.gradle.nativeplatform.test.NativeTestSuiteBinarySpec) StaticLibraryBinarySpec(org.gradle.nativeplatform.StaticLibraryBinarySpec) Spec(org.gradle.api.specs.Spec) NativeExecutableBinarySpec(org.gradle.nativeplatform.NativeExecutableBinarySpec) NativeBinarySpec(org.gradle.nativeplatform.NativeBinarySpec) FileCollection(org.gradle.api.file.FileCollection) CompositeFileCollection(org.gradle.api.internal.file.CompositeFileCollection)

Example 13 with Transformer

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());
        }
    };
}
Also used : Transformer(org.gradle.api.Transformer) List(java.util.List) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) PrintWriter(java.io.PrintWriter)

Aggregations

Transformer (org.gradle.api.Transformer)13 File (java.io.File)6 List (java.util.List)5 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 UncheckedIOException (org.gradle.api.UncheckedIOException)2 ConfigurableFileCollection (org.gradle.api.file.ConfigurableFileCollection)2 FileCollection (org.gradle.api.file.FileCollection)2 HeaderExportingSourceSet (org.gradle.language.nativeplatform.HeaderExportingSourceSet)2 SharedLibraryBinarySpec (org.gradle.nativeplatform.SharedLibraryBinarySpec)2 PrintWriter (java.io.PrintWriter)1 Path (java.nio.file.Path)1 WatchEvent (java.nio.file.WatchEvent)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 Action (org.gradle.api.Action)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 Project (org.gradle.api.Project)1 Task (org.gradle.api.Task)1