arturdm / jacoco-android-gradle-plugin

Gradle plugin that creates JaCoCo test reports for Android unit tests
Apache License 2.0
561 stars 111 forks source link

Jacoco Task taking forever #60

Open bschnack opened 5 years ago

bschnack commented 5 years ago

The Jacoco Task sometimes takes forever to run. Sometimes, it runs immediately and other times, it just gets stuck doing the same task over and over again. You can see the gradle task in the picture below. The gradle file (slimmed down to important info) looks like: build.gradle Project Level

buildscript {
    dependencies {
        classpath('com.dicedmelon.gradle:jacoco-android:0.1.3') { exclude group: 'org.codehaus.groovy', module: 'groovy-all' }
    }
}

build.gradle App Level

apply plugin: 'jacoco-android'

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

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

image

arturdm commented 5 years ago

@bschnack could you try again with 0.1.4?

bschnack commented 5 years ago

So far that seems to have worked. However, we still see that the Jacoco task takes a while to run. Is there a way to only have it run with a certain command line argument or improve that time?

Thanks, Brian

image

hoda0013 commented 4 years ago

I am seeing similar behavior with 0.1.4. It only happens intermittently but occasionally I'll the jacocoDevDebug job running for 5 to 10 minutes.

mochadwi commented 4 years ago

I've tried below approach:

  1. gradle.startParameter.excludedTaskNames += "jacocoDevelopDebug" in custom task, or overwriting it, e.g:
    
    // kotlin gradle
    task.replace("assemble[Flavour]Debug").doLast { 
    gradle.startParameter.excludedTaskNames += "jacoco[Flavour]Debug"
    }

// groovy gradle task jar(overwrite: true) { gradle.startParameter.excludedTaskNames += "jacoco[Flavour]Debug" }

[See original issue here](https://github.com/gradle/gradle/issues/8335#issue-402961082) & [here (about kotlin gradle)](https://stackoverflow.com/q/48553029/3763032)

---
2. Using parameter in command line, e.g: 

./gradlew -PnoLint // or ./gradlew -x lint

[See original article here](https://stackoverflow.com/a/46918139/3763032) & [here](https://kousenit.org/2016/04/20/excluding-gradle-tasks-with-a-name-pattern/)

---
3. Flagging based on command line argument & separating jacoco task gradle file

if (System.getProperty("myJacocoArguments").toBoolean()) { apply: jacoco.gradle }

[See here for more detail](https://stackoverflow.com/a/42507517/3763032)

---
4. Disable test coverage on local development, and run only on jenkins/CI server
    testCoverageEnabled (project.hasProperty('coverage') ? true : false)

[Original article](https://jeroenmols.com/blog/2016/09/01/coveragecost/)
nateridderman-lilly commented 4 years ago

This is happening to me, but I'm not even using this plugin. I'm using https://github.com/vanniktech/gradle-android-junit-jacoco-plugin

pp-lucaal-sportsbet commented 3 years ago

This is still happening for 50 per cent of the build. Any way to fix this or to get rid of the plugin all together?

Sinapse87 commented 3 years ago

Unfortunately this issue is still happening. Has anyone been able to find a workaround?