Skip to content

Commit

Permalink
Java coverage is now generated conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
stanbrub committed Jan 22, 2025
1 parent fac6ad2 commit a5a5ea0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 32 deletions.
22 changes: 0 additions & 22 deletions buildSrc/src/main/groovy/TestTools.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,6 @@ By default only runs in CI; to run locally:
.replace "${separator}test$separator", "$separator$type$separator"
(report as SimpleReport).outputLocation.set new File(rebased)
}
// this is not part of the standard class; it is glued on later by jacoco plugin;
// we want to give each test it's own output files for jacoco analysis,
// so we don't accidentally stomp on previous output.
// TODO: verify jenkins is analyzing _all_ information here.
if (project.findProperty('jacoco.enabled') == "true") {
(t['jacoco'] as JacocoTaskExtension).with {
destinationFile = project.provider({ new File(project.buildDir, "jacoco/${type}.exec".toString()) } as Callable<File>)
classDumpDir = new File(project.buildDir, "jacoco/${type}Dumps".toString())
}
(project['jacocoTestReport'] as JacocoReport).with {
reports {
JacocoReportsContainer c ->
c.xml.enabled = true
c.csv.enabled = true
c.html.enabled = true
}
}
}

}
if (project.findProperty('jacoco.enabled') == "true") {
project.tasks.findByName('jacocoTestReport').mustRunAfter(t)
}

return t
Expand Down
22 changes: 22 additions & 0 deletions buildSrc/src/main/groovy/io.deephaven.coverage-merge.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id 'base'
id 'jacoco-report-aggregation'
}

jacoco {
toolVersion = '0.8.12'
}

tasks.register("coverage-merge", JacocoReport) {
def jprojects = allprojects.findAll { p-> p.plugins.hasPlugin('java') }
additionalSourceDirs = files(jprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(jprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(jprojects.sourceSets.main.output)
reports {
html.required = true
csv.required = true
xml.required = false
}
def projRootDir = project.rootDir.absolutePath
executionData fileTree(projRootDir).include("**/build/jacoco/*.exec")
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ plugins {
}

jacoco {
toolVersion = '0.8.8'
toolVersion = '0.8.12'
}

test {
jacoco {
destinationFile = layout.buildDirectory.file('jacoco/jacoco.exec').get().asFile
}
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.enabled true
csv.enabled true
html.enabled true
csv.required = true
csv.destination = layout.buildDirectory.file('reports/jacoco/java-coverage.csv').get().asFile
xml.required = true
xml.outputLocation = layout.buildDirectory.file('reports/jacoco/java-coverage.xml').get().asFile
html.outputLocation = layout.buildDirectory.dir('reports/jacoco/html')
}
}

project.tasks.withType(Test).all { Test t ->
finalizedBy jacocoTestReport
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ plugins {
id 'java'
}

if (project.findProperty('jacoco.enabled') == 'true') {
// Only load if jacoco enabled; otherwise
// instrumentation of the code is still done.
// Apply Jacoco instrumentation and coverage reporting
if (project.findProperty('coverage.enabled') == 'true') {
project.apply plugin: 'io.deephaven.java-jacoco-conventions'
rootProject.apply plugin: 'io.deephaven.coverage-merge'
}

def testJar = project.tasks.register 'testJar', Jar, { Jar jar ->
Expand Down

0 comments on commit a5a5ea0

Please sign in to comment.