Search in sources :

Example 1 with JarCreator

use of com.google.devtools.build.buildjar.jarhelper.JarCreator in project bazel by bazelbuild.

the class IdlClass method writeOutputJar.

/** Writes the generated class files to the output jar. */
private static void writeOutputJar(Path outputJar, Path tempDir) throws IOException {
    JarCreator output = new JarCreator(outputJar.toString());
    output.setCompression(true);
    output.setNormalize(true);
    output.addDirectory(tempDir.toString());
    output.execute();
}
Also used : JarCreator(com.google.devtools.build.buildjar.jarhelper.JarCreator)

Example 2 with JarCreator

use of com.google.devtools.build.buildjar.jarhelper.JarCreator in project bazel by bazelbuild.

the class ResourceJarBuilder method build.

public void build() throws IOException {
    requireNonNull(options.output());
    final JarCreator jar = new JarCreator(options.output());
    build(jar);
    jar.execute();
}
Also used : JarCreator(com.google.devtools.build.buildjar.jarhelper.JarCreator)

Example 3 with JarCreator

use of com.google.devtools.build.buildjar.jarhelper.JarCreator in project bazel by bazelbuild.

the class VanillaJavaBuilder method writeGeneratedSourceOutput.

/** Writes a jar containing any sources generated by annotation processors. */
private static void writeGeneratedSourceOutput(OptionsParser optionsParser) throws IOException {
    if (optionsParser.getGeneratedSourcesOutputJar() == null) {
        return;
    }
    JarCreator jar = new JarCreator(optionsParser.getGeneratedSourcesOutputJar());
    jar.setNormalize(true);
    jar.setCompression(optionsParser.compressJar());
    jar.addDirectory(optionsParser.getSourceGenDir());
    jar.execute();
}
Also used : JarCreator(com.google.devtools.build.buildjar.jarhelper.JarCreator)

Example 4 with JarCreator

use of com.google.devtools.build.buildjar.jarhelper.JarCreator in project bazel by bazelbuild.

the class VanillaJavaBuilder method writeOutput.

/** Writes the class output jar, including any resource entries. */
private static void writeOutput(OptionsParser optionsParser) throws IOException {
    JarCreator jar = new JarCreator(optionsParser.getOutputJar());
    jar.setNormalize(true);
    jar.setCompression(optionsParser.compressJar());
    jar.addDirectory(optionsParser.getClassDir());
    // TODO(cushon): kill this once resource jar creation is decoupled from JavaBuilder
    try (ResourceJarBuilder resourceBuilder = new ResourceJarBuilder(ResourceJarOptions.builder().setMessages(ImmutableList.copyOf(optionsParser.getMessageFiles())).setResourceJars(ImmutableList.copyOf(optionsParser.getResourceJars())).setResources(ImmutableList.copyOf(optionsParser.getResourceFiles())).setClasspathResources(ImmutableList.copyOf(optionsParser.getRootResourceFiles())).build())) {
        resourceBuilder.build(jar);
    }
    jar.execute();
}
Also used : JarCreator(com.google.devtools.build.buildjar.jarhelper.JarCreator) ResourceJarBuilder(com.google.devtools.build.buildjar.resourcejar.ResourceJarBuilder)

Example 5 with JarCreator

use of com.google.devtools.build.buildjar.jarhelper.JarCreator in project bazel by bazelbuild.

the class JacocoInstrumentationProcessor method processRequest.

/**
   * Instruments classes using Jacoco and keeps copies of uninstrumented class files in
   * jacocoMetadataDir, to be zipped up in the output file jacocoMetadataOutput.
   */
public void processRequest(JavaLibraryBuildRequest build) throws IOException {
    // running JavaBuilder locally, to remove stale entries from previous builds.
    if (metadataDir != null) {
        Path workDir = Paths.get(metadataDir);
        if (Files.exists(workDir)) {
            recursiveRemove(workDir);
        }
        Files.createDirectories(workDir);
    }
    JarCreator jar = new JarCreator(metadataOutput);
    jar.setNormalize(true);
    jar.setCompression(build.compressJar());
    Instrumenter instr = new Instrumenter(new OfflineInstrumentationAccessGenerator());
    // TODO(bazel-team): not sure whether Emma did anything fancier than this (multithreaded?)
    instrumentRecursively(instr, Paths.get(build.getClassDir()));
    jar.addDirectory(metadataDir);
    jar.execute();
}
Also used : Path(java.nio.file.Path) JarCreator(com.google.devtools.build.buildjar.jarhelper.JarCreator) OfflineInstrumentationAccessGenerator(org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator) Instrumenter(org.jacoco.core.instr.Instrumenter)

Aggregations

JarCreator (com.google.devtools.build.buildjar.jarhelper.JarCreator)8 Path (java.nio.file.Path)2 ResourceJarBuilder (com.google.devtools.build.buildjar.resourcejar.ResourceJarBuilder)1 IOException (java.io.IOException)1 FileVisitResult (java.nio.file.FileVisitResult)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1 Instrumenter (org.jacoco.core.instr.Instrumenter)1 OfflineInstrumentationAccessGenerator (org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator)1