Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buildscript {
- ext {
- ....
- }
- repositories {
- mavenCentral()
- maven {
- ....
- }
- }
- dependencies {
- .....
- }
- }
- apply plugin: 'java'
- apply plugin: 'eclipse'
- apply plugin: 'idea'
- apply plugin: 'jacoco'
- jar {
- baseName = "coverage-test"
- }
- dependencies {
- // my dependencies
- }
- eclipse {
- classpath {
- containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
- containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
- }
- }
- wrapper {
- gradleVersion = '3.4.1'
- }
- jacoco {
- toolVersion = '0.7.9'
- }
- jacocoTestReport {
- reports {
- xml.enabled false
- csv.enabled false
- }
- group = "Reporting"
- description = "Generate Jacoco coverage reports after running tests."
- additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
- afterEvaluate {
- classDirectories = files(classDirectories.files.collect {
- fileTree(
- dir: it,
- excludes:
- [
- 'com/jacoco/dto/**',
- 'com/jacoco/configs/**',
- //and others
- ])
- })
- }
- }
- jacocoTestCoverageVerification {
- //I tried this and it didn't work
- // classDirectories = files(classDirectories.files.collect {
- // fileTree(
- // dir: it,
- // excludes:
- // [
- // 'com/jacoco/dto/**',
- // 'com/jacoco/configs/**',
- // //and others
- // ])
- // })
- violationRules {
- rule {
- //Also tried this and it didn't work
- // excludes = ['com/jacoco/dto/**', ...]
- limit {
- counter = 'BRANCH'
- minimum = 0.8
- }
- }
- }
- }
- check.dependsOn jacocoTestCoverageVerification
- violationRules {
- rule {
- element = 'CLASS'
- excludes = ['com.jacoco.dto.*']
- limit {
- counter = 'BRANCH'
- minimum = 0.8
- }
- }
- }
- check.dependsOn jacocoTestCoverageVerification
- afterEvaluate {
- classDirectories = files(classDirectories.files.collect {
- fileTree(dir: it, exclude: [
- 'com/example/my/package/*',
- 'com/example/service/MyApplication.kt',
- 'com/google/protobuf/*'
- ])
- })
- }
- apply plugin: "jacoco”
- jacocoTestCoverageVerification {
- afterEvaluate {
- classDirectories = files(classDirectories.files.collect {
- fileTree(dir: it, exclude: [
- 'com/example/my/package/*',
- 'com/example/service/MyApplication.kt',
- 'com/google/protobuf/*'
- ])
- })
- }
- violationRules {
- rule {
- limit {
- minimum = 0.79
- }
- }
- }
- }
- // to run coverage verification during the build (and fail when appropriate)
- check.dependsOn jacocoTestCoverageVerification
Add Comment
Please, Sign In to add comment