Skip to content

Commit

Permalink
Try to switch to JaCoCo
Browse files Browse the repository at this point in the history
  • Loading branch information
aNNiMON committed May 30, 2019
1 parent f29fd57 commit 9c3b7f1
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ before_install:
- chmod +x gradlew

after_success:
- ./gradlew cobertura coveralls sonarqube
- ./gradlew jacocoTestReport coveralls sonarqube
# - mvn cobertura:cobertura coveralls:report
86 changes: 68 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,42 +1,92 @@
// Plugins
plugins {
id "net.saliman.cobertura" version "2.2.6"
id "com.github.kt3k.coveralls" version "2.8.1"
id 'jacoco'
id "com.github.kt3k.coveralls" version "2.8.2"
id "me.champeau.gradle.jmh" version "0.4.4"
id "org.sonarqube" version "2.6.2"
id "org.sonarqube" version "2.7"
}

def publishedProjects = subprojects.findAll { it.path != ':test' }

allprojects {
repositories {
mavenCentral()
}

apply plugin: 'jacoco'
apply plugin: 'java'

jacoco {
toolVersion = '0.8.3'
}
}

subprojects {
apply plugin: 'net.saliman.cobertura'
cobertura {
coverageFormats = ['html', 'xml']
jacocoTestReport {
additionalSourceDirs = files(sourceSets.main.allSource.srcDirs)
classDirectories = files(sourceSets.main.output)
sourceDirectories = files(sourceSets.main.allSource.srcDirs)

reports {
xml.enabled true
html.enabled true
html.destination "${buildDir}/reports/jacoco"
}

afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'**/com/annimon/stream/internal/Compat**',
'**/com/annimon/stream/test/hamcrest/CommonMatcher**'
])
})
}
}
}

cobertura {
coverageFormats = ['html', 'xml']
coverageExcludes = ['.*com\\.annimon\\.stream\\.internal\\.Compat.*', '.*com\\.annimon\\.stream\\.test\\.hamcrest\\.CommonMatcher.*']
coverageReportDatafile = file("build/cobertura/cobertura.ser")
coverageReportDir = file("build/reports/coverage")
coverageSourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()
coverageMergeDatafiles = subprojects.collect { file("${it.buildDir}/cobertura/cobertura.ser") }
coverageDirs = subprojects.sourceSets.main.output.classesDirs.collect { it.getFiles() }
task jacocoMerge(type: JacocoMerge) {
publishedProjects.each { subproject ->
executionData subproject.tasks
}
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)
classDirectories = files(publishedProjects.sourceSets.main.output)
sourceDirectories = files(publishedProjects.sourceSets.main.allSource.srcDirs)
executionData = files(publishedProjects.jacocoTestReport.executionData)

reports {
xml.enabled true
html.enabled true
html.destination "${buildDir}/reports/jacoco"
}

doFirst {
executionData = files(executionData.findAll {
it.exists()
})
}
}
}

coveralls {
coberturaReportPath = "${rootProject.buildDir}/reports/coverage/coverage.xml"
sourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}

test.dependsOn(rootProject.subprojects.collect { ":${it.name}:cobertura" })
test.dependsOn(rootProject.subprojects.collect { ":${it.name}:jacocoRootReport" })

tasks.coveralls {
dependsOn coberturaReport
group = 'Coverage reports'
description = 'Uploads the aggregated coverage report to Coveralls'

onlyIf { System.env.'CI' }
}

sonarqube {
Expand Down
6 changes: 3 additions & 3 deletions stream/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ dependencies {
testImplementation project(':streamTest')
}

cobertura {
coverageExcludes = ['.*com\\.annimon\\.stream\\.internal\\.Compat.*']
}
//cobertura {
// coverageExcludes = ['.*com\\.annimon\\.stream\\.internal\\.Compat.*']
//}

jmh {
benchmarkMode = ['Throughput']
Expand Down
6 changes: 3 additions & 3 deletions streamTest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.12'
}

cobertura {
coverageExcludes = ['.*com\\.annimon\\.stream\\.test\\.hamcrest\\.CommonMatcher.*']
}
//cobertura {
// coverageExcludes = ['.*com\\.annimon\\.stream\\.test\\.hamcrest\\.CommonMatcher.*']
//}

// maven signing
if (ext.isReleaseVersion) {
Expand Down

0 comments on commit 9c3b7f1

Please sign in to comment.