Gradle JacocoTestReports task skips on bamboo build server but builds on local machine

I have a gradle script with a test task using Jacoco for reporting. The build.gradle file looks like this:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
}
apply plugin: 'com.android.application'
apply plugin: 'jacoco'
apply plugin: "sonar-runner"

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 21
    buildToolsVersion '22.0.1'

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"

        testHandleProfiling true
        testFunctionalTest true
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            testCoverageEnabled true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    apply plugin: 'android-unit-test'

    dependencies {
        testCompile 'org.easytesting:fest:1.0.16'
        testCompile 'junit:junit:4.10'
        testCompile 'org.robolectric:robolectric:2.4'
        testCompile 'com.squareup:fest-android:1.0.8'
    }
}

def coverageSourceDirs = [
        '../app/src/main/java', 'src/gen'
]

task jacocoTestReport(type: JacocoReport, dependsOn: "testDebug") {
    group = "Reporting"
    description = "Generate Jacoco coverage reports after running tests."
    reports {
        xml.enabled = true
        html.enabled = true
    }

    classDirectories = fileTree(
            dir: './build/intermediates/classes/debug',
            excludes: ['**/R.class',
                       '**/R$*.class'
            ])
    sourceDirectories = files(coverageSourceDirs)
    executionData = files('build/jacoco/testDebug.exec')
}

sonarRunner {

    sonarProperties {

        property "sonar.projectKey", "coverage-example"
        property "sonar.projectName", "Coverage Example"
        property "sonar.projectVersion", "1.0"

        property "sonar.sources", "src/main/java"
        property "sonar.binaries", "build"
        property "sonar.test", "src/test/java"

        property "sonar.language", "java"
        property "sonar.profile", "Android Lint"
        property "sonar.android.lint.report", "lint-report.xml"
        property "sonar.dynamicAnalysis", "reuseReports"
        property "sonar.sourceEncoding", "UTF-8"

        property "sonar.junit.reportsPath", "build/outputs/reports/coverage/debug"
        property "sonar.cobertura.reportPath", "build/outputs/reports/coverage/debug/cobertura.xml"
        property "sonar.java.coveragePlugin", "cobertura"

        property "sonar.host.url", "https://sonar.domain.com"

        property "sonar.jdbc.url", "jdbc:mysql://sonar.domain.com:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance"

        property "sonar.jdbc.username", "someuser"
        property "sonar.jdbc.password", "somepass"
    }

}

      

Running on local machine all tests run and I get reports as expected. But while working on a bamboo server, I see in the log that the task is skipped:

build   05-May-2015 16:19:24    :app:validateDebugSigning
build   05-May-2015 16:19:25    :app:packageDebug
build   05-May-2015 16:19:25    :app:zipalignDebug
build   05-May-2015 16:19:25    :app:assembleDebug
build   05-May-2015 16:19:25    :app:compileTestDebugJava
build   05-May-2015 16:19:25    :app:processTestDebugResources UP-TO-DATE
build   05-May-2015 16:19:25    :app:testDebugClasses
build   05-May-2015 16:19:25    :app:testDebug
build   05-May-2015 16:19:25    :app:jacocoTestReport SKIPPED
build   05-May-2015 16:19:26    :app:sonarRunner
build   05-May-2015 16:19:26    SonarQube Runner 2.3
build   05-May-2015 16:19:26    Java 1.7.0_79 Oracle Corporation (64-bit)
build   05-May-2015 16:19:26    Linux 3.13.0-46-generic amd64
build   05-May-2015 16:19:26    INFO: Runner configuration file: NONE
build   05-May-2015 16:19:26    INFO: Project configuration file: /bamboo/xml-data/build-dir/TSTIOSAPPA-TP-BDA/app/build/tmp/sonarRunner/sonar-project.properties
build   05-May-2015 16:19:26    INFO: Default locale: "en_US", source code encoding: "UTF-8"
build   05-May-2015 16:19:26    INFO: Work directory: /bamboo/xml-data/build-dir/TSTIOSAPPA-TP-BDA/app/build/sonar
build   05-May-2015 16:19:26    INFO: SonarQube Server 5.1

      

Since I have no errors, I don't understand what the problem is. gradle is executed with gradle -wrapper, so it builds the same version on both machines. Any ideas?

EDIT:

I looked at Running jacocoReport , but it doesn't really explain why it is running on my local machine and not on the build server . And if I add a test task (with a java plugin), I get the following error:

The 'java' plugin has been applied, but it is not compatible with the Android plugins.

      

And if I don't apply the java plugin, I get the following error:

Could not find method test() for arguments [build_58yd8leqt3uhm31fecj9zk2qm$_run_closure4@3a73cd3f] on project ':app'.

      

But maybe I am completely confused about how to use the test problem? Could not find test () method for arguments [build_58yd8leqt3uhm31fecj9zk2qm $ _run_closure4 @ 3a73cd3f] in project ': app'.

+3


source to share


1 answer


The jacocoTestReport task is skipped when there is no coverage data to process.

Coverage data is generated when the tests are run. In android, the androidTest task will execute the tests.



To generate a jacoco report, you have to run the tests with a line like this:

.\gradlew androidTest

      

+1


source







All Articles