Skip to content

Commit

Permalink
Add config flag to disable jacoco
Browse files Browse the repository at this point in the history
(cherry picked from commit 5236c49)
  • Loading branch information
famod authored and gsmet committed Feb 20, 2024
1 parent 7374ac8 commit 5e1e0aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.jacoco.core.instr.Instrumenter;
import org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator;
import org.jboss.jandex.ClassInfo;
import org.jboss.logging.Logger;

import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.bootstrap.workspace.SourceDir;
Expand All @@ -36,6 +37,8 @@

public class JacocoProcessor {

private static final Logger log = Logger.getLogger(JacocoProcessor.class);

@BuildStep(onlyIf = IsTest.class)
FeatureBuildItem feature() {
return new FeatureBuildItem("jacoco");
Expand All @@ -53,6 +56,10 @@ void transformerBuildItem(BuildProducer<BytecodeTransformerBuildItem> transforme
//no code coverage for continuous testing, it does not really make sense
return;
}
if (!config.enabled) {
log.debug("quarkus-jacoco is disabled via config");
return;
}

String dataFile = getFilePath(config.dataFile, outputTargetBuildItem.getOutputDirectory(),
JacocoConfig.JACOCO_QUARKUS_EXEC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ public class JacocoConfig {
public static final String TARGET_JACOCO_QUARKUS_EXEC = "target/" + JACOCO_QUARKUS_EXEC;
public static final String TARGET_JACOCO_REPORT = "target/" + JACOCO_REPORT;

/**
* Whether or not the jacoco extension is enabled. Disabling it can come in handy when runnig tests in IDEs that do their
* own jacoco instrumentation, e.g. EclEmma in Eclipse.
*/
@ConfigItem(defaultValue = "true")
public boolean enabled;

/**
* The jacoco data file.
* The path can be relative (to the module) or absolute.
Expand Down

0 comments on commit 5e1e0aa

Please sign in to comment.