diff --git a/circle.yml b/circle.yml index e293e643420..1fac4b01c4d 100644 --- a/circle.yml +++ b/circle.yml @@ -64,6 +64,11 @@ jobs: # --device model=sailfish,version=26,locale=es,orientation=portrait \ # --device model=walleye,version=28,locale=de,orientation=landscape \ # --timeout 5m + - run: + name: Post code coverage report to Codecov.io + command: | + cd mapbox-navigation-android && ./gradlew testDebugUnitTestCoverage + pip install --user codecov && /root/.local/bin/codecov - run: name: Run robo test on Firebase no_output_timeout: 1200 diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 5bbaa9d5c08..e756b13f46f 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -101,7 +101,6 @@ ext { pluginVersion = [ checkstyle : '8.2', pmd : '5.8.1', - jacoco : '0.8.1', errorprone : '0.0.13', coveralls : '2.8.1', spotbugs : '1.3', diff --git a/gradle/jacoco.gradle b/gradle/jacoco.gradle index dbe0ba31e6e..7e4533c75d7 100644 --- a/gradle/jacoco.gradle +++ b/gradle/jacoco.gradle @@ -1,68 +1,37 @@ apply plugin: 'jacoco' -jacoco { - toolVersion = pluginVersion.jacoco -} - -android { - testOptions { - unitTests.all { - jacoco { - includeNoLocationClasses = true - } - } - } -} - project.afterEvaluate { - //Gather build type and product flavor names in a list + // Grab all build types and product flavors def buildTypes = android.buildTypes.collect { type -> type.name } - def productFlavors = android.productFlavors.collect { flavor -> flavor.name } - if (!productFlavors) productFlavors.add('') - - productFlavors.each { productFlavorName -> - buildTypes.each { buildTypeName -> - - //Define the sourceName and the sourcePath. - def sourceName, sourcePath - if (!productFlavorName) { - sourceName = sourcePath = "${buildTypeName}" - } else { - sourceName = "${productFlavorName}${buildTypeName.capitalize()}" - sourcePath = "${productFlavorName}/${buildTypeName}" - } - - def testTaskName = "test${sourceName.capitalize()}UnitTest" - //noinspection GroovyAssignabilityCheck - task "create${sourceName.capitalize()}UnitTestCoverageReport"(type: JacocoReport, dependsOn: "$testTaskName") { + buildTypes.each { buildTypeName -> + def sourceName, sourcePath + sourceName = sourcePath = "${buildTypeName}" + def testTaskName = "test${sourceName.capitalize()}UnitTest" + def coverageTaskName = "${testTaskName}Coverage" - group = "Reporting" - description = - "Generate Jacoco coverage reports on the ${sourceName.capitalize()} build." + // Create coverage task of form 'testFlavorTypeUnitTestCoverage' depending on 'testFlavorTypeUnitTest' + task "${coverageTaskName}"(type: JacocoReport, dependsOn: "$testTaskName") { + group = 'Reporting' + description = "Generate Jacoco coverage reports for the ${sourceName.capitalize()} build." - //Directory where the compiled class files are - classDirectories = - fileTree(dir: "${project.buildDir}/intermediates/classes/${sourcePath}", - excludes: [ - '**/R.class', - '**/R$*.class', - '**/*$ViewInjector*.*', - '**/*$ViewBinder*.*', - '**/BuildConfig.*', - '**/Manifest*.*', - '**/*$Lambda$*.*', // Jacoco can not handle several "$" in class name. - '**/*_Provide*Factory*.*', - '**/*$*$*.*' // Anonymous classes generated by kotlin - ]) + classDirectories = fileTree( + dir: "${project.buildDir}/intermediates/javac/${sourcePath}", + excludes: ['**/R.class', + '**/R$*.class', + '**/BuildConfig.*', + '**/Manifest*.*']) - sourceDirectories = files(["src/main/java", - "src/$productFlavorName/java", - "src/$buildTypeName/java"]) + sourceDirectories = files(["src/main/java", + "src/$buildTypeName/java"]) - executionData = files("${project.buildDir}/jacoco/${testTaskName}.exec") + executionData = files("${project.buildDir}/jacoco/${testTaskName}.exec") + reports { + xml.enabled = true + html.enabled = true } } + build.dependsOn "${coverageTaskName}" } -} \ No newline at end of file +}