Android Jacoco测试,按Gradle-dependsOn顺序,使用CompiledBugSources和CompiledBugTestSources
像这样的其他地方将有一个依赖于testDebug的JacoTestReport任务。这很有效Android Jacoco测试,按Gradle-dependsOn顺序,使用CompiledBugSources和CompiledBugTestSources,android,gradle,jacoco,Android,Gradle,Jacoco,像这样的其他地方将有一个依赖于testDebug的JacoTestReport任务。这很有效 task jacocoTestReport(type: JacocoReport, dependsOn: "testDebug") { ... } 然而,在我的例子中,除了testDebug之外,我还需要依赖android任务compiledbugsources和compiledbugtestsources。所以我希望下面的方法能奏效 task jacocoTestReport(type: J
task jacocoTestReport(type: JacocoReport, dependsOn: "testDebug") {
...
}
然而,在我的例子中,除了testDebug之外,我还需要依赖android任务compiledbugsources和compiledbugtestsources。所以我希望下面的方法能奏效
task jacocoTestReport(type: JacocoReport, dependsOn: ["compileDebugSources", "compileDebugTestSources", "testDebug"]) {
...
}
但是,当我使用dependsOn属性或方法时,这些依赖项的顺序并不能像Gradle所说的那样得到保证。因此,我想在任务之外做如下事情
testDebug.mustRunAfter compileDebugSources
testDebug.mustRunAfter compileDebugTestSources
但我发现上面的编译问题是,testDebug或compiledBugSources或compiledBugTestSources在project:app上被标记为“找不到属性‘testDebug/compiledBugSources/compiledBugTestSources’”
我想知道我需要做些什么才能为gradle中现有的JacoTestReport任务添加这些任务的顺序。试试以下方法:
task jacocoTestReport(type: JacocoReport, dependsOn: ["compileDebugSources", "compileDebugTestSources", "testDebug"]) { ... }
tasks.testDebug.dependsOn(compileDebugTestSources)
tasks.compileDebugTestSources.dependsOn(compileDebugSources)