Search in sources :

Example 1 with OfflineInstrumentationAccessGenerator

use of org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator 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)1 Path (java.nio.file.Path)1 Instrumenter (org.jacoco.core.instr.Instrumenter)1 OfflineInstrumentationAccessGenerator (org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator)1