我有一个简单的Java项目,我正在用Gradle 1.9构建一些测试。我正在尝试将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方面的经验很少。
谢谢!
发布于 2013-11-28 15:48:13
您没有在构建中定义存储库。对很多人来说,那就是Maven Central。
repositories {
mavenCentral()
}在指向lib文件夹时,您似乎希望自己管理库。我想这些库是用源代码签入的吧?如果同样的策略应该适用于JaCoCo库,那么您将需要将它们放在那里,并将它们分配给JaCoCo插件的配置。
https://stackoverflow.com/questions/20269761
复制相似问题