diff --git a/build.gradle b/build.gradle index 2a90a7f6..312c2bb0 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,7 @@ plugins { id 'idea' id 'se.patrikerdes.use-latest-versions' version '0.2.18' id 'com.github.ben-manes.versions' version '0.51.0' + id 'jacoco' } // Add ability to test with upcoming versions of Groovy @@ -62,6 +63,7 @@ allprojects { apply plugin: 'idea' apply plugin: 'groovy' apply plugin: 'java-library' + apply plugin: 'jacoco' java { toolchain { @@ -88,6 +90,48 @@ allprojects { maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } } + test { + useJUnitPlatform() + finalizedBy jacocoTestReport // report is always generated after tests run + } + + jacoco { + toolVersion = "0.8.12" + reportsDirectory = layout.buildDirectory.dir('reports/jacoco') + } + + jacocoTestReport { + dependsOn test // tests are required to run before generating the report + reports { + xml.required = false + csv.required = false + html.outputLocation = layout.buildDirectory.dir('jacocoHtml') + } + } + + jacocoTestCoverageVerification { + violationRules { + rule { + limit { + minimum = 0.5 + } + } + + rule { + enabled = false + element = 'CLASS' + includes = ['org.gradle.*'] + + limit { + counter = 'LINE' + value = 'TOTALCOUNT' + maximum = 0.3 + } + } + } + } + + configurations { // see https://docs.gradle.org/4.1/userguide/dependency_management.html#sub:exclude_transitive_dependencies all*.exclude group: 'org.codehaus.groovy', module: 'groovy-all' diff --git a/plugins/nf-quilt/build.gradle b/plugins/nf-quilt/build.gradle index 840650a2..e4bbba97 100644 --- a/plugins/nf-quilt/build.gradle +++ b/plugins/nf-quilt/build.gradle @@ -20,10 +20,11 @@ plugins { id 'idea' id 'se.patrikerdes.use-latest-versions' version '0.2.18' id 'com.github.ben-manes.versions' version '0.51.0' + id 'jacoco' } useLatestVersions { - // A blacklist of dependencies to update, in the format of group:name + // A blacklist of dependencies to not update, in the format of group:name updateBlacklist = [ 'com.quiltdata:quiltcore', 'org.codehaus.groovy:groovy', @@ -113,5 +114,41 @@ dependencies { // use JUnit 5 platform test { useJUnitPlatform() + finalizedBy jacocoTestReport // report is always generated after tests run } +jacoco { + toolVersion = "0.8.12" + reportsDirectory = layout.buildDirectory.dir('reports/jacoco') +} + +jacocoTestReport { + dependsOn test // tests are required to run before generating the report + reports { + xml.required = false + csv.required = false + html.outputLocation = layout.buildDirectory.dir('jacocoHtml') + } +} + +jacocoTestCoverageVerification { + violationRules { + rule { + limit { + minimum = 0.5 + } + } + + rule { + enabled = false + element = 'CLASS' + includes = ['org.gradle.*'] + + limit { + counter = 'LINE' + value = 'TOTALCOUNT' + maximum = 0.3 + } + } + } +}