【发布时间】:2013-11-28 15:26:29
【问题描述】:
我有一个简单的 Java 项目,其中包含一些我正在使用 Gradle 1.9 构建的测试。我正在尝试按照以下说明将 Jacoco 添加到构建中:http://www.gradle.org/docs/current/userguide/jacoco_plugin.html
当我运行时:gradle clean build jacocoTestReport 我得到以下构建失败:
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
我的 build.gradle 文件是:
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."
}
谁能告诉我我错过了什么?我怀疑 Jacoco 插件文档可能已过时或与最新版本的 Gradle 不兼容,但目前我对 Gradle 的经验很少。
谢谢!
【问题讨论】: