Skip to content

Commit

Permalink
Add Jacoco
Browse files Browse the repository at this point in the history
  • Loading branch information
hamid-rocket committed Mar 23, 2018
1 parent 7a42134 commit e3a76e9
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 6 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
@@ -0,0 +1,21 @@
language: android
jdk: oraclejdk8
env:
global:
- ANDROID_TARGET=android-16
- ANDROID_ABI=armeabi-v7a
- BUILD_TOOLS_VERSION=27.0.3
- ANDROID_TARGET=27
android:
components:
- tools
- platform-tools
- build-tools-${BUILD_TOOLS_VERSION}
- android-${ANDROID_TARGET}
- extra-google-m2repository
- extra-android-m2repository
- sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
script:
- ./gradlew build jacocoTestReport
after_success:
- bash <(curl -s https://codecov.io/bash)
1 change: 1 addition & 0 deletions build.gradle
Expand Up @@ -10,6 +10,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:3.2.0-alpha06'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath 'org.jacoco:org.jacoco.core:0.8.0'
}
}

Expand Down
18 changes: 13 additions & 5 deletions restring/bintray.gradle
Expand Up @@ -44,19 +44,27 @@ artifacts {
/*--------------------------------*/

// Bintray
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
String localProperty(propertyName) {
Properties properties = new Properties()
File file = project.rootProject.file('local.properties')
if (file.exists()) {
properties.load(file.newDataInputStream())
return properties.getProperty(propertyName)
}
return ""
}

bintray {
user = properties.getProperty("bintrayUser")
key = properties.getProperty("bintrayApiKey")
user = localProperty("bintrayUser")
key = localProperty("bintrayApiKey")

configurations = ['archives']
pkg {
repo = bintrayRepo
name = bintrayName
desc = libraryDescription
userOrg = organization // If the repository is hosted by an organization instead of personal account.
userOrg = organization
// If the repository is hosted by an organization instead of personal account.
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
Expand Down
7 changes: 6 additions & 1 deletion restring/build.gradle
@@ -1,4 +1,5 @@
apply plugin: 'com.android.library'
apply from: 'jacoco.gradle'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand All @@ -15,6 +16,10 @@ android {
}

buildTypes {
debug {
minifyEnabled false
testCoverageEnabled true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Expand All @@ -28,7 +33,7 @@ android {

testOptions {
unitTests {
includeAndroidResources true
includeAndroidResources = true
}
}
}
Expand Down
27 changes: 27 additions & 0 deletions restring/jacoco.gradle
@@ -0,0 +1,27 @@
apply plugin: 'jacoco'

jacoco {
toolVersion = '0.8.0'
}

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}

task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {

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

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
def debugTree = fileTree(dir: "$project.buildDir/intermediates/artifact_transform/compileDebugJavaWithJavac/classes", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"

sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
])
}

0 comments on commit e3a76e9

Please sign in to comment.