Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Jacoco from running in default gradle task (which happens on every local build)

We have Jacoco running, but have noticed that Jacoco runs in the normal Android Studio build (such as pressing "Run" to deploy changes). This adds an unnecessary amount of time into the build time. I would rather only run Jacoco on demand (by an explicit gradle task) rather than have it included in every Android Studio build.

enter image description here

jacoco.gradle:

apply plugin: 'jacoco-android'

jacocoAndroidUnitTestReport {
    csv.enabled true
    html.enabled false
    xml.enabled false
}

app.gradle:

android {
 testOptions {
        animationsDisabled true
        unitTests {
            includeAndroidResources = true
        }
        unitTests.all {
            jvmArgs '-noverify'
            jacoco {
                includeNoLocationClasses = true
            }
        }
    }
}

apply from: "jacoco.gradle"
like image 988
fobbymaster Avatar asked Dec 09 '25 19:12

fobbymaster


1 Answers

this is coming from apply plugin: 'jacoco-android' ...it's not the default behavior.

if you'd define the task in jacoco.gradle, this should not happen, unless explicitly running the task.

or you could try do disable the generation of the task (possibly this has to be per flavor dev):

android {
    buildTypes {
        debug {
            testCoverageEnabled false
        }
    }
}
like image 79
Martin Zeitler Avatar answered Dec 11 '25 11:12

Martin Zeitler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!