diff --git a/.travis.yml b/.travis.yml index 1cea1a0ae..d74607cc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,3 +22,5 @@ branches: only: - master - /^\d+\.\d+\.\d+(-SNAPSHOT|-alpha|-beta)?\d*$/ # trigger builds on tags which are semantically versioned to ship the SDK. +after_success: + - ./gradlew coveralls uploadArchives --console plain diff --git a/build.gradle b/build.gradle index bfea9deb5..0d6ebc9f0 100644 --- a/build.gradle +++ b/build.gradle @@ -12,13 +12,24 @@ buildscript { } plugins { - id 'nebula.optional-base' version '3.2.0' + id 'com.github.kt3k.coveralls' version '2.8.2' + id 'jacoco' id 'me.champeau.gradle.jmh' version '0.3.1' + id 'nebula.optional-base' version '3.2.0' } allprojects { group = 'com.optimizely.ab' apply plugin: 'idea' + apply plugin: 'jacoco' + + repositories { + jcenter() + } + + jacoco { + toolVersion = '0.8.0' + } } apply from: 'gradle/publish.gradle' @@ -33,8 +44,8 @@ allprojects { subprojects { apply plugin: 'com.jfrog.bintray' apply plugin: 'findbugs' - apply plugin: 'java' apply plugin: 'jacoco' + apply plugin: 'java' apply plugin: 'maven-publish' apply plugin: 'me.champeau.gradle.jmh' apply plugin: 'nebula.optional-base' @@ -170,9 +181,49 @@ subprojects { task ship() { dependsOn('bintrayUpload') } + } task ship() { dependsOn(':core-api:ship', ':core-httpclient-impl:ship') } +// Only report code coverage for projects that are distributed +def publishedProjects = subprojects.findAll { it.path != ':simulator' } + +task jacocoMerge(type: JacocoMerge) { + publishedProjects.each { subproject -> + executionData subproject.tasks.withType(Test) + } + doFirst { + executionData = files(executionData.findAll { it.exists() }) + } +} + +task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') { + description = 'Generates an aggregate report from all subprojects' + dependsOn publishedProjects.test, jacocoMerge + + additionalSourceDirs = files(publishedProjects.sourceSets.main.allSource.srcDirs) + sourceDirectories = files(publishedProjects.sourceSets.main.allSource.srcDirs) + classDirectories = files(publishedProjects.sourceSets.main.output) + executionData jacocoMerge.destinationFile + + reports { + html.enabled = true // human readable + xml.enabled = true // required by coveralls + } +} + +coveralls { + sourceDirs = publishedProjects.sourceSets.main.allSource.srcDirs.flatten() + jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml" +} + +tasks.coveralls { + group = 'Coverage reports' + description = 'Uploads the aggregated coverage report to Coveralls' + + dependsOn jacocoRootReport + onlyIf { System.env.'CI' && !JavaVersion.current().isJava9Compatible() } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 01b8bf6b1..c44b679ac 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 933b6473c..568c50bf3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip