[英]Android Jacoco Test with Gradle dependsOn order with compileDebugSources and compileDebugTestSources
Other places like This Other Question will have a jacocoTestReport task that depends on testDebug. 诸如“ 其他问题”之类的其他地方将具有依赖于testDebug的jacocoTestReport任务。 Which works.
哪个有效。
task jacocoTestReport(type: JacocoReport, dependsOn: "testDebug") {
...
}
However, in my case, I need to also depend on the android tasks compileDebugSources and compileDebugTestSources in addition to the testDebug. 但是,就我而言,除了testDebug之外,我还需要依赖android任务compileDebugSources和compileDebugTestSources。 So I was hoping that the following would work
所以我希望以下方法能起作用
task jacocoTestReport(type: JacocoReport, dependsOn: ["compileDebugSources", "compileDebugTestSources", "testDebug"]) {
...
}
However, when I use the dependsOn property or method, the order of these dependencies aren't guaranteed as stated by Gradle. 但是,当我使用dependsOn属性或方法时,如Gradle所述,不能保证这些依赖项的顺序。 So I wanted to do something like the following outside of the task
所以我想在任务之外做类似下面的事情
testDebug.mustRunAfter compileDebugSources
testDebug.mustRunAfter compileDebugTestSources
but I get a compilation problem with the above is that testDebug or compileDebugSources or compileDebugTestSources gets marked as being "Could not find property 'testDebug/compileDebugSources/compileDebugTestSources'" on project :app 但是上面的编译问题是在项目:app上将testDebug或compileDebugSources或compileDebugTestSources标记为“找不到属性'testDebug / compileDebugSources / compileDebugTestSources'”
I'm wondering what I need to do in order to add the order of these tasks for my existing jacocoTestReport task in gradle. 我想知道如何为gradle中现有的jacocoTestReport任务添加这些任务的顺序。
Try this: 尝试这个:
task jacocoTestReport(type: JacocoReport, dependsOn: ["compileDebugSources", "compileDebugTestSources", "testDebug"]) { ... }
tasks.testDebug.dependsOn(compileDebugTestSources)
tasks.compileDebugTestSources.dependsOn(compileDebugSources)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.