From 34f797ba79d3dbb59765c6a1d03fda6d8751e300 Mon Sep 17 00:00:00 2001 From: Sam Judd Date: Sun, 2 Nov 2014 09:48:59 -0800 Subject: [PATCH] Add jacoco coverage report. --- .travis.yml | 1 + build.gradle | 1 + gradle.properties | 1 + library/build.gradle | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/.travis.yml b/.travis.yml index 14fe933d2..c1a2a27c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,4 @@ script: 'travis_retry ./gradlew build --parallel' after_success: - scripts/travis-sonatype-publish.sh +- ./gradlew jacocoTestReport coveralls diff --git a/build.gradle b/build.gradle index d964f80fc..afee8a702 100644 --- a/build.gradle +++ b/build.gradle @@ -10,6 +10,7 @@ buildscript { dependencies { classpath "org.robolectric:robolectric-gradle-plugin:${ROBOLECTRIC_GRADLE_VERSION}" classpath "com.android.tools.build:gradle:${ANDROID_GRADLE_VERSION}" + classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:${COVERALLS_GRADLE_VERSION}" } } diff --git a/gradle.properties b/gradle.properties index 329061a78..31dc1885d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,6 +21,7 @@ OK_HTTP_VERSION=2.0.0 ANDROID_GRADLE_VERSION=0.13.3 ROBOLECTRIC_GRADLE_VERSION=0.12.0 +COVERALLS_GRADLE_VERSION=2.0.1 JUNIT_VERSION=4.11 MOCKITO_VERSION=1.9.5 ROBOLECTRIC_VERSION=2.4-SNAPSHOT diff --git a/library/build.gradle b/library/build.gradle index b913861a1..03213f287 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -3,10 +3,18 @@ apply plugin: 'robolectric' apply plugin: 'maven' apply plugin: 'findbugs' apply plugin: 'pmd' +apply plugin: 'jacoco' +apply plugin: 'com.github.kt3k.coveralls' findbugs { toolVersion = "2.0.3" } +jacoco { + toolVersion = "0.7.1.201405082137" +} +coveralls { + jacocoReportPath = 'build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml' +} dependencies { compile project(':third_party:gif_decoder') @@ -36,6 +44,12 @@ android { versionCode = VERSION_CODE versionName = VERSION_NAME } + + buildTypes { + debug { + testCoverageEnabled = true + } + } } afterEvaluate { @@ -86,4 +100,29 @@ afterEvaluate { } check.dependsOn('pmd') + + task jacocoTestReport(type:JacocoReport, dependsOn: testDebug) { + def coverageSourceDirs = ['src/main/java'] + group = "Reporting" + + description = "Generate Jacoco coverage reports" + + classDirectories = fileTree( + dir: 'build/intermediates/classes/debug', + excludes: ['**/R.class', + '**/R$*.class', + '**/*$ViewInjector*.*', + '**/BuildConfig.*', + '**/Manifest*.*'] + ) + + additionalSourceDirs = files(coverageSourceDirs) + sourceDirectories = files(coverageSourceDirs) + executionData = files('build/jacoco/testDebug.exec') + + reports { + xml.enabled = true + html.enabled = true + } + } } -- GitLab