diff --git a/.travis.yml b/.travis.yml index 14fe933d28c32895731b4f79658482b311221273..c1a2a27c1eaa31b12bd2c527c4cfeeca6c89e0c5 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 d964f80fcad1329a64c4a00d2135530c64c787e5..afee8a702628f7b0f29583863f0a739134c97fa9 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 329061a782434c12fa252ccef970d65f78cc7866..31dc1885d21d9660e2abe08b31c580ee16117211 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 b913861a10336355c9893e9e613affe0e7bd3f38..03213f2875a5e50d296a94ef0956e647c858bce4 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 + } + } }