Skip to content

Commit

Permalink
Merge pull request #41 from auth0/fix-coverage
Browse files Browse the repository at this point in the history
Fix JaCoCo coverage reports
  • Loading branch information
hzalaz authored Nov 24, 2016
2 parents 319ce45 + e04c5f2 commit 239a4d0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion auth0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

apply plugin: 'com.android.library'
apply plugin: 'jacoco-android'
apply from: '../scripts/jacoco.gradle'

def semver = defineVersion()
version = semver.stringVersion
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1'
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
Expand Down
56 changes: 56 additions & 0 deletions scripts/jacoco.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apply plugin: 'jacoco'

jacoco {
// https://bintray.com/bintray/jcenter/org.jacoco:org.jacoco.core
toolVersion = "0.7.7.201606060606"
}

android {
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
}

project.afterEvaluate {

def jacocoTestReportTask = tasks.findByName("jacocoTestReport")
if (!jacocoTestReportTask) {
jacocoTestReportTask = tasks.create("jacocoTestReport")
jacocoTestReportTask.group = "Reporting"
jacocoTestReportTask.description = "Generate Jacoco coverage reports for all builds."
}

android.libraryVariants.all { variant ->
def name = variant.name
def testTaskName = "test${name.capitalize()}UnitTest"

def reportTask = tasks.create(name: "jacocoTest${name.capitalize()}UnitTestReport", type: JacocoReport, dependsOn: "$testTaskName") {
group = "Reporting"
description = "Generate Jacoco coverage reports for the ${name.capitalize()} build."

classDirectories = fileTree(
dir: "${project.buildDir}/intermediates/classes/${name}",
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/*$ViewBinder*.*',
'**/BuildConfig.*',
'**/Manifest*.*']
)

sourceDirectories = files(['src/main/java'].plus(android.sourceSets[name].java.srcDirs))
executionData = files("${project.buildDir}/jacoco/${testTaskName}.exec")

reports {
xml.enabled = true
html.enabled = true
}
}

jacocoTestReportTask.dependsOn reportTask
}
}

0 comments on commit 239a4d0

Please sign in to comment.