其他地方,如This Other Question,将有一个依赖于testDebug的jacocoTestReport任务。这是可行的。
task jacocoTestReport(type: JacocoReport, dependsOn: "testDebug") {
...
}然而,在我的例子中,除了testDebug之外,我还需要依赖android任务compileDebugSources和compileDebugTestSources。所以我希望下面的方法能行得通
task jacocoTestReport(type: JacocoReport, dependsOn: ["compileDebugSources", "compileDebugTestSources", "testDebug"]) {
...
}但是,当我使用dependsOn属性或方法时,这些依赖项的顺序并不像Gradle所说的那样得到保证。因此,我想在任务之外做一些类似以下的事情
testDebug.mustRunAfter compileDebugSources
testDebug.mustRunAfter compileDebugTestSources但我在上面的代码中遇到了一个编译问题,即testDebug、compileDebugSources或compileDebugTestSources被标记为“找不到项目上的属性app:
我想知道我需要做什么才能在gradle中为我现有的jacocoTestReport任务添加这些任务的顺序。
发布于 2015-02-16 21:05:30
试试这个:
task jacocoTestReport(type: JacocoReport, dependsOn: ["compileDebugSources", "compileDebugTestSources", "testDebug"]) { ... }
tasks.testDebug.dependsOn(compileDebugTestSources)
tasks.compileDebugTestSources.dependsOn(compileDebugSources)https://stackoverflow.com/questions/27830696
复制相似问题