diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1a369a0 --- /dev/null +++ b/.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) \ No newline at end of file diff --git a/build.gradle b/build.gradle index 49afdeb..b5e1656 100644 --- a/build.gradle +++ b/build.gradle @@ -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' } } diff --git a/restring/bintray.gradle b/restring/bintray.gradle index 7096011..53e8414 100644 --- a/restring/bintray.gradle +++ b/restring/bintray.gradle @@ -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 diff --git a/restring/build.gradle b/restring/build.gradle index 6fa4af6..0bd570a 100644 --- a/restring/build.gradle +++ b/restring/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.library' +apply from: 'jacoco.gradle' android { compileSdkVersion rootProject.ext.compileSdkVersion @@ -15,6 +16,10 @@ android { } buildTypes { + debug { + minifyEnabled false + testCoverageEnabled true + } release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' @@ -28,7 +33,7 @@ android { testOptions { unitTests { - includeAndroidResources true + includeAndroidResources = true } } } diff --git a/restring/jacoco.gradle b/restring/jacoco.gradle new file mode 100644 index 0000000..d8d4b54 --- /dev/null +++ b/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' + ]) +} \ No newline at end of file