org.gradle.internal.IoActions Java Examples

The following examples show how to use org.gradle.internal.IoActions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClasspathAddingInitScriptBuilder.java    From paraphrase with Apache License 2.0 6 votes vote down vote up
public void build(File initScriptFile, final List<File> classpath) {
  IoActions.writeTextFile(initScriptFile, new ErroringAction<Writer>() {
    @Override
    protected void doExecute(Writer writer) throws Exception {
      writer.write("allprojects {\n");
      writer.write("  buildscript {\n");
      writer.write("    dependencies {\n");
      writer.write("      classpath files(\n");
      int i = 0;
      for (File file : classpath) {
        writer.write(
            String.format("        '%s'", TextUtil.escapeString(file.getAbsolutePath())));
        if (++i != classpath.size()) {
          writer.write(",\n");
        }
      }
      writer.write("\n");
      writer.write("      )\n");
      writer.write("    }\n");
      writer.write("  }\n");
      writer.write("}\n");
    }
  });
}
 
Example #2
Source File: JavadocOptionFileWriter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
void write(File outputFile) throws IOException {
    IoActions.writeTextFile(outputFile, new ErroringAction<BufferedWriter>() {
        @Override
        protected void doExecute(BufferedWriter writer) throws Exception {
            final Map<String, JavadocOptionFileOption> options = new TreeMap<String, JavadocOptionFileOption>(optionFile.getOptions());
            JavadocOptionFileWriterContext writerContext = new JavadocOptionFileWriterContext(writer);

            JavadocOptionFileOption localeOption = options.remove("locale");
            if (localeOption != null) {
                localeOption.write(writerContext);
            }

            for (final String option : options.keySet()) {
                options.get(option).write(writerContext);
            }

            optionFile.getSourceNames().write(writerContext);
        }
    });
}
 
Example #3
Source File: JavadocOptionFileWriter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
void write(File outputFile) throws IOException {
    IoActions.writeTextFile(outputFile, new ErroringAction<BufferedWriter>() {
        @Override
        protected void doExecute(BufferedWriter writer) throws Exception {
            final Map<String, JavadocOptionFileOption<?>> options = new TreeMap<String, JavadocOptionFileOption<?>>(optionFile.getOptions());
            JavadocOptionFileWriterContext writerContext = new JavadocOptionFileWriterContext(writer);

            JavadocOptionFileOption<?> localeOption = options.remove("locale");
            if (localeOption != null) {
                localeOption.write(writerContext);
            }

            for (final String option : options.keySet()) {
                options.get(option).write(writerContext);
            }

            optionFile.getSourceNames().write(writerContext);
        }
    });
}
 
Example #4
Source File: JavadocOptionFileWriter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
void write(File outputFile) throws IOException {
    IoActions.writeTextFile(outputFile, new ErroringAction<BufferedWriter>() {
        @Override
        protected void doExecute(BufferedWriter writer) throws Exception {
            final Map<String, JavadocOptionFileOption<?>> options = new TreeMap<String, JavadocOptionFileOption<?>>(optionFile.getOptions());
            JavadocOptionFileWriterContext writerContext = new JavadocOptionFileWriterContext(writer);

            JavadocOptionFileOption<?> localeOption = options.remove("locale");
            if (localeOption != null) {
                localeOption.write(writerContext);
            }

            for (final String option : options.keySet()) {
                options.get(option).write(writerContext);
            }

            optionFile.getSourceNames().write(writerContext);
        }
    });
}
 
Example #5
Source File: JavadocOptionFileWriter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
void write(File outputFile) throws IOException {
    IoActions.writeTextFile(outputFile, new ErroringAction<BufferedWriter>() {
        @Override
        protected void doExecute(BufferedWriter writer) throws Exception {
            final Map<String, JavadocOptionFileOption> options = new TreeMap<String, JavadocOptionFileOption>(optionFile.getOptions());
            JavadocOptionFileWriterContext writerContext = new JavadocOptionFileWriterContext(writer);

            JavadocOptionFileOption localeOption = options.remove("locale");
            if (localeOption != null) {
                localeOption.write(writerContext);
            }

            for (final String option : options.keySet()) {
                options.get(option).write(writerContext);
            }

            optionFile.getSourceNames().write(writerContext);
        }
    });
}
 
Example #6
Source File: GradleBuildComparison.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void writeReport(final BuildComparisonResult result, final File reportDir, FileStore<String> fileStore, final Map<String, String> hostAttributes) {
    if (reportDir.exists() && reportDir.list().length > 0) {
        GFileUtils.cleanDirectory(reportDir);
    }

    fileStore.moveFilestore(new File(reportDir, FILES_DIR_NAME));

    final Charset encoding = Charset.defaultCharset();
    IoActions.writeTextFile(new File(reportDir, HTML_REPORT_FILE_NAME), encoding.name(), new Action<BufferedWriter>() {
        public void execute(BufferedWriter writer) {
            createResultRenderer(encoding, reportDir, hostAttributes).render(result, writer);
        }
    });
}
 
Example #7
Source File: DefaultManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public org.gradle.api.java.archives.Manifest writeTo(Object path) {
    IoActions.writeTextFile(fileResolver.resolve(path), new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            writeTo(writer);
        }
    });
    return this;
}
 
Example #8
Source File: HtmlReportRenderer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T> void renderHtmlPage(final String name, final T model, final ReportRenderer<T, HtmlPageBuilder<SimpleHtmlWriter>> renderer) {
    File outputFile = new File(outputDirectory, name);
    IoActions.writeTextFile(outputFile, "utf-8", new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            SimpleHtmlWriter htmlWriter = new SimpleHtmlWriter(writer, "");
            htmlWriter.startElement("html");
            renderer.render(model, new DefaultHtmlPageBuilder<SimpleHtmlWriter>(prefix(name), htmlWriter));
            htmlWriter.endElement();
        }
    });
}
 
Example #9
Source File: HtmlReportRenderer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T> void renderRawHtmlPage(final String name, final T model, final ReportRenderer<T, HtmlPageBuilder<Writer>> renderer) {
    File outputFile = new File(outputDirectory, name);
    IoActions.writeTextFile(outputFile, "utf-8", new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            renderer.render(model, new DefaultHtmlPageBuilder<Writer>(prefix(name), writer));
        }
    });
}
 
Example #10
Source File: XmlTransformer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void transform(File destination, final String encoding, final Action<? super Writer> generator) {
    IoActions.writeTextFile(destination, encoding, new Action<Writer>() {
        public void execute(Writer writer) {
            transform(writer, encoding, generator);
        }
    });
}
 
Example #11
Source File: XmlTransformer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void transform(File destination, final Action<? super Writer> generator) {
    IoActions.writeTextFile(destination, new Action<Writer>() {
        public void execute(Writer writer) {
            transform(writer, generator);
        }
    });
}
 
Example #12
Source File: DefaultMavenPom.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultMavenPom writeTo(Object path) {
    IoActions.writeTextFile(fileResolver.resolve(path), POM_FILE_ENCODING, new Action<BufferedWriter>() {
        public void execute(BufferedWriter writer) {
            writeTo(writer);
        }
    });
    return this;
}
 
Example #13
Source File: GradleBuildComparison.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void writeReport(final BuildComparisonResult result, final File reportDir, FileStore<String> fileStore, final Map<String, String> hostAttributes) {
    if (reportDir.exists() && reportDir.list().length > 0) {
        GFileUtils.cleanDirectory(reportDir);
    }

    fileStore.moveFilestore(new File(reportDir, FILES_DIR_NAME));

    final Charset encoding = Charset.defaultCharset();
    IoActions.writeTextFile(new File(reportDir, HTML_REPORT_FILE_NAME), encoding.name(), new Action<BufferedWriter>() {
        public void execute(BufferedWriter writer) {
            createResultRenderer(encoding, reportDir, hostAttributes).render(result, writer);
        }
    });
}
 
Example #14
Source File: TextReportRenderer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Renders the report for the given model to a file.
 */
public void writeTo(final T model, File file) {
    IoActions.writeTextFile(file, "utf-8", new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            writeTo(model, writer);
        }
    });
}
 
Example #15
Source File: XmlTransformer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void transform(File destination, final String encoding, final Action<? super Writer> generator) {
    IoActions.writeTextFile(destination, encoding, new Action<Writer>() {
        public void execute(Writer writer) {
            transform(writer, encoding, generator);
        }
    });
}
 
Example #16
Source File: XmlTransformer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void transform(File destination, final Action<? super Writer> generator) {
    IoActions.writeTextFile(destination, new Action<Writer>() {
        public void execute(Writer writer) {
            transform(writer, generator);
        }
    });
}
 
Example #17
Source File: DefaultManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public org.gradle.api.java.archives.Manifest writeTo(Object path) {
    IoActions.writeTextFile(fileResolver.resolve(path), new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            writeTo(writer);
        }
    });
    return this;
}
 
Example #18
Source File: DefaultMavenPom.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultMavenPom writeTo(Object path) {
    IoActions.writeTextFile(fileResolver.resolve(path), POM_FILE_ENCODING, new Action<BufferedWriter>() {
        public void execute(BufferedWriter writer) {
            writeTo(writer);
        }
    });
    return this;
}
 
Example #19
Source File: DefaultManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public org.gradle.api.java.archives.Manifest writeTo(Object path) {
    IoActions.writeTextFile(fileResolver.resolve(path), new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            writeTo(writer);
        }
    });
    return this;
}
 
Example #20
Source File: DefaultManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public org.gradle.api.java.archives.Manifest writeTo(Object path) {
    IoActions.writeTextFile(fileResolver.resolve(path), new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            writeTo(writer);
        }
    });
    return this;
}
 
Example #21
Source File: XmlTransformer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void transform(File destination, final Action<? super Writer> generator) {
    IoActions.writeTextFile(destination, new Action<Writer>() {
        public void execute(Writer writer) {
            transform(writer, generator);
        }
    });
}
 
Example #22
Source File: XmlTransformer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void transform(File destination, final String encoding, final Action<? super Writer> generator) {
    IoActions.writeTextFile(destination, encoding, new Action<Writer>() {
        public void execute(Writer writer) {
            transform(writer, encoding, generator);
        }
    });
}
 
Example #23
Source File: TextReportRenderer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Renders the report for the given model to a file.
 */
public void writeTo(final T model, File file) {
    IoActions.writeTextFile(file, "utf-8", new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            writeTo(model, writer);
        }
    });
}
 
Example #24
Source File: GradleBuildComparison.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void writeReport(final BuildComparisonResult result, final File reportDir, FileStore<String> fileStore, final Map<String, String> hostAttributes) {
    if (reportDir.exists() && reportDir.list().length > 0) {
        GFileUtils.cleanDirectory(reportDir);
    }

    fileStore.moveFilestore(new File(reportDir, FILES_DIR_NAME));

    final Charset encoding = Charset.defaultCharset();
    IoActions.writeTextFile(new File(reportDir, HTML_REPORT_FILE_NAME), encoding.name(), new Action<BufferedWriter>() {
        public void execute(BufferedWriter writer) {
            createResultRenderer(encoding, reportDir, hostAttributes).render(result, writer);
        }
    });
}
 
Example #25
Source File: DefaultMavenPom.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultMavenPom writeTo(Object path) {
    IoActions.writeTextFile(fileResolver.resolve(path), POM_FILE_ENCODING, new Action<BufferedWriter>() {
        public void execute(BufferedWriter writer) {
            writeTo(writer);
        }
    });
    return this;
}
 
Example #26
Source File: XmlTransformer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void transform(File destination, final Action<? super Writer> generator) {
    IoActions.writeTextFile(destination, new Action<Writer>() {
        public void execute(Writer writer) {
            transform(writer, generator);
        }
    });
}
 
Example #27
Source File: XmlTransformer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void transform(File destination, final String encoding, final Action<? super Writer> generator) {
    IoActions.writeTextFile(destination, encoding, new Action<Writer>() {
        public void execute(Writer writer) {
            transform(writer, encoding, generator);
        }
    });
}
 
Example #28
Source File: HtmlReportRenderer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T> void renderRawHtmlPage(final String name, final T model, final ReportRenderer<T, HtmlPageBuilder<Writer>> renderer) {
    File outputFile = new File(outputDirectory, name);
    IoActions.writeTextFile(outputFile, "utf-8", new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            renderer.render(model, new DefaultHtmlPageBuilder<Writer>(prefix(name), writer));
        }
    });
}
 
Example #29
Source File: HtmlReportRenderer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T> void renderHtmlPage(final String name, final T model, final ReportRenderer<T, HtmlPageBuilder<SimpleHtmlWriter>> renderer) {
    File outputFile = new File(outputDirectory, name);
    IoActions.writeTextFile(outputFile, "utf-8", new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            SimpleHtmlWriter htmlWriter = new SimpleHtmlWriter(writer, "");
            htmlWriter.startElement("html");
            renderer.render(model, new DefaultHtmlPageBuilder<SimpleHtmlWriter>(prefix(name), htmlWriter));
            htmlWriter.endElement();
        }
    });
}
 
Example #30
Source File: GradleBuildComparison.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void writeReport(final BuildComparisonResult result, final File reportDir, FileStore<String> fileStore, final Map<String, String> hostAttributes) {
    if (reportDir.exists() && reportDir.list().length > 0) {
        GFileUtils.cleanDirectory(reportDir);
    }

    fileStore.moveFilestore(new File(reportDir, FILES_DIR_NAME));

    final Charset encoding = Charset.defaultCharset();
    IoActions.writeTextFile(new File(reportDir, HTML_REPORT_FILE_NAME), encoding.name(), new Action<BufferedWriter>() {
        public void execute(BufferedWriter writer) {
            createResultRenderer(encoding, reportDir, hostAttributes).render(result, writer);
        }
    });
}