Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Jacoco测试,按Gradle-dependsOn顺序,使用CompiledBugSources和CompiledBugTestSources_Android_Gradle_Jacoco - Fatal编程技术网

Android Jacoco测试,按Gradle-dependsOn顺序,使用CompiledBugSources和CompiledBugTestSources

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

像这样的其他地方将有一个依赖于testDebug的JacoTestReport任务。这很有效

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)