From 115df70b5c21323c25e900924db1342ee20bedb2 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Fri, 21 Dec 2018 21:27:19 +0100 Subject: [PATCH] Fix coverage reports --- cameraview/build.gradle | 44 +++++++++++++++++++++++++++-------------- codecov.yml | 2 +- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/cameraview/build.gradle b/cameraview/build.gradle index 36a7ca22..37eff082 100644 --- a/cameraview/build.gradle +++ b/cameraview/build.gradle @@ -189,27 +189,41 @@ task mergedCoverageReport(type: JacocoReport) { dependsOn "testDebugUnitTest" dependsOn "connectedCheck" - def testData = "jacoco/testDebugUnitTest.exec" - def androidTestData = "outputs/code-coverage/connected/*coverage.ec" - executionData = fileTree(dir: "$buildDir", includes: [testData, androidTestData]) - - // Sources. - sourceDirectories = android.sourceSets.main.java.sourceFiles - // Add BuildConfig and R. - additionalSourceDirs = files([ + // Merge unit tests and android tests data + executionData = fileTree(dir: "$buildDir", includes: [ + "jacoco/testDebugUnitTest.exec", // Unit tests + "outputs/code-coverage/connected/*coverage.ec" // Android tests + ]) + + // Sources + sourceDirectories = files(android.sourceSets.main.java.sourceFiles) + additionalSourceDirs = files([ // Add BuildConfig and R. "$buildDir/generated/source/buildConfig/debug", "$buildDir/generated/source/r/debug" ]) - // Classes. - def debugDir = "$buildDir/intermediates/classes/debug" - def filter = ['**/R.class', '**/R$*.class', '**/*$ViewInjector*.*', - '**/BuildConfig.*', '**/Manifest*.*'] - classDirectories = fileTree(dir: debugDir, excludes: filter); + // Classes (.class files) + // Not everything in the filter relates to CameraView, + // but let's keep a generic filter + def classDir = "$buildDir/intermediates/javac/debug" + def classFilter = [ + '**/R.class', + '**/R$*.class', + '**/BuildConfig.*', + '**/Manifest*.*', + 'android/**', + 'androidx/**', + 'com/google/**', + '**/*$ViewInjector*.*', + '**/Dagger*Component.class', + '**/Dagger*Component$Builder.class', + '**/*Module_*Factory.class', + ] + classDirectories = fileTree(dir: classDir, excludes: classFilter); - reports.xml.enabled = true reports.html.enabled = true - reports.xml.destination = "$reportsDirectory/mergedCoverageReport/report.xml" + reports.xml.enabled = true + reports.xml.destination file("$reportsDirectory/mergedCoverageReport/report.xml") } //endregion diff --git a/codecov.yml b/codecov.yml index 87486942..3c22eb79 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,7 +6,7 @@ coverage: status: project: default: - target: 50% + target: 45% patch: default: target: 70%