Skip to content

integrate coveralls #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 26, 2018
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
55 changes: 53 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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() }
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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