如何让 sonarqube 依赖 jacocoTestReport?
How do I get sonarqube to depend on jacocoTestReport?
为什么这行不通,我怎样才能得到我想要的结果?具体来说,我希望 jacoco 在 sonarqube 之前 运行。
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
test {
jacoco {
excludes = [...,
"javolution.*"]
}
}
jacocoTestReport {
dependsOn tasks.withType(Test)//This makes integrationTests go.
}
//This is the part that I can't get to work:
project.tasks["sonarqube"].dependsOn jacocoTestReport
}
错误是:
* Where:
Build file '/dev/abc/build.gradle' line: 92
* What went wrong:
A problem occurred evaluating root project 'abc'.
> Task with name 'sonarqube' not found in project ':thingamajig'.
当然thingamajig
是一个空的父目录。那里没有 build.gradle
,但它有许多子目录确实有 build.gradle
。我已经尝试了很多事情,比如检查任务图和在调用 project.tasks.getByName()
时捕获异常,我猜是时候下注了。
子项目没有自己的声纳运行器任务。使根项目 sonar runner 任务依赖于子项目 jacocoTestReport 任务。
在我的 build.gradle
中看起来像
if (hasProperty('sonarAnalyseOnly') && sonarAnalyseOnly.toBoolean()) {
tasks.sonarRunner.dependsOn = []
} else {
tasks.sonarRunner.dependsOn {
project.subprojects.findAll { !it.sonarRunner.skipProject }.collect {
[
it.tasks.compileSharedJava,
it.tasks.compileServerJava,
it.tasks.compileGuiJava,
it.tasks.integTest,
it.tasks.jacocoMerge
]
}.flatten()
}
}
为什么这行不通,我怎样才能得到我想要的结果?具体来说,我希望 jacoco 在 sonarqube 之前 运行。
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
test {
jacoco {
excludes = [...,
"javolution.*"]
}
}
jacocoTestReport {
dependsOn tasks.withType(Test)//This makes integrationTests go.
}
//This is the part that I can't get to work:
project.tasks["sonarqube"].dependsOn jacocoTestReport
}
错误是:
* Where:
Build file '/dev/abc/build.gradle' line: 92
* What went wrong:
A problem occurred evaluating root project 'abc'.
> Task with name 'sonarqube' not found in project ':thingamajig'.
当然thingamajig
是一个空的父目录。那里没有 build.gradle
,但它有许多子目录确实有 build.gradle
。我已经尝试了很多事情,比如检查任务图和在调用 project.tasks.getByName()
时捕获异常,我猜是时候下注了。
子项目没有自己的声纳运行器任务。使根项目 sonar runner 任务依赖于子项目 jacocoTestReport 任务。
在我的 build.gradle
中看起来像
if (hasProperty('sonarAnalyseOnly') && sonarAnalyseOnly.toBoolean()) {
tasks.sonarRunner.dependsOn = []
} else {
tasks.sonarRunner.dependsOn {
project.subprojects.findAll { !it.sonarRunner.skipProject }.collect {
[
it.tasks.compileSharedJava,
it.tasks.compileServerJava,
it.tasks.compileGuiJava,
it.tasks.integTest,
it.tasks.jacocoMerge
]
}.flatten()
}
}