我试图创建一个Jacoco报告使用一个Gradle任务的一个Android项目。我想从报告中排除一些未经测试的文件,但它们仍然出现在网络报告中。
这是我定义的分级任务:
apply plugin: 'jacoco' jacoco { // Use this version for upper ones are broken (with Gradle) // https://github.com/jacoco/jacoco/issues/288 toolVersion = "0.7.1.201405082137" def coverageSourceDirs = [ 'src/main/java/....', task createJacocoReport(type: JacocoReport) { println ":${project.name}:Generating Jacoco reports" group = "Reporting" description = "Generate Jacoco coverage reports after running tests." reports { xml.enabled = true xml.destination = "${buildDir}/jacocoReport.xml" csv.enabled = true csv.destination = "${buildDir}/jacocoReport.csv" html.enabled = true html.destination = "${buildDir}/jacocoHtml" classDirectories = fileTree(dir: './build/intermediates/classes/release', excludes: ['**/R$*.class', '**/R.class', '**/android/**/*.class', '**/google/**/*.class', '**/Activities/*.class', '**/Fragments/*.class', '**/Views/*.class', '**/NativeImplementations/*.class',