Domanda

I have a simple Java project with some tests that I am building with Gradle 1.9. I am attempting to add Jacoco to the build following instructions at: http://www.gradle.org/docs/current/userguide/jacoco_plugin.html

When I run:gradle clean build jacocoTestReport I get the following build failure:

FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':test'.
    > Could not resolve all dependencies for configuration ':jacocoAgent'.
       > Could not find org.jacoco:org.jacoco.agent:0.6.2.201302030002.
         Required by:
             :Phoenix:1.0

My build.gradle file is:

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'sonar-runner'

sourceCompatibility = 1.7
version = '1.0'

test {
  // enable TestNG support (default is JUnit)
  useTestNG()

  // listen to events in the test execution lifecycle
  beforeTest { descriptor ->
     logger.lifecycle("Running test: " + descriptor)
  }

  // listen to standard out and standard error of the test JVM(s)
  onOutput { descriptor, event ->
     logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
  }
}

sourceSets {
    main {
        java {
            srcDir 'src'
        }
    }
    test {
        java {
            srcDir 'test'
        }
    }
}

jar {
    manifest {
        attributes 'Implementation-Title': 'SQLWriter', 'Implementation-Version': version
    }
}

dependencies {
    compile files('./lib/commons-codec-1.6.jar')
    runtime files('./lib/hamcrest-core-1.3.jar')
    runtime files('./lib/sqlite-jdbc-3.7.2.jar')
    compile files('./lib/testng-6.8.jar')
    runtime files('./lib/testng-6.8.jar')
}

task doc(type: Javadoc) {
  source = sourceSets.main.allJava
}

jacoco {
    toolVersion = "0.6.2.201302030002"
    reportsDir = file("$buildDir/customJacocoReportDir")
}

jacocoTestReport {
    group = "Reporting"
    description = "Generate Jacoco coverage reports after running tests."
}

Can anyone tell me what I'm missing? I suspect that the Jacoco plugin documentation may be out of date or incompatible with the latest version of Gradle, but I have very little experience with Gradle at this point.

Thanks!

È stato utile?

Soluzione

You are not defining a repository in your build. For many people that would be Maven Central.

repositories {
    mavenCentral()
}

It seems as if you want to manage your libraries yourself as you are pointing to the lib folder. I assume these libraries are checked in with your source code? If the same strategy should apply to the JaCoCo libraries then you will need to put them there and assign them to the configurations of the JaCoCo plugin.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top