|
| 1 | +plugins { |
| 2 | + id 'org.springframework.boot' version '2.7.0' |
| 3 | + id 'io.spring.dependency-management' version '1.0.11.RELEASE' |
| 4 | + id 'java' |
| 5 | + id 'jacoco' |
| 6 | +} |
| 7 | + |
| 8 | +group = 'sk.cyrilgavala' |
| 9 | +sourceCompatibility = '11' |
| 10 | + |
| 11 | +repositories { |
| 12 | + mavenCentral() |
| 13 | +} |
| 14 | + |
| 15 | +dependencies { |
| 16 | + /* Annotation processors */ |
| 17 | + annotationProcessor group: 'org.projectlombok', name: 'lombok-mapstruct-binding', version: '0.1.0' |
| 18 | + annotationProcessor group: 'org.mapstruct', name: 'mapstruct-processor', version: mapStructVersion |
| 19 | + annotationProcessor group: 'org.projectlombok', name: 'lombok', version: lombokVersion |
| 20 | + |
| 21 | + /* Implementation dependencies */ |
| 22 | + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-mongodb', version: springBootVersion |
| 23 | + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: springBootVersion |
| 24 | + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: springBootVersion |
| 25 | + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: springBootVersion |
| 26 | + implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: jjwtVersion |
| 27 | + implementation group: 'io.jsonwebtoken', name: 'jjwt-impl', version: jjwtVersion |
| 28 | + implementation group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: jjwtVersion |
| 29 | + implementation group: 'org.mapstruct', name: 'mapstruct', version: mapStructVersion |
| 30 | + implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2' |
| 31 | + implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.8' |
| 32 | + |
| 33 | + /* Compile only dependencies */ |
| 34 | + compileOnly group: 'org.projectlombok', name: 'lombok', version: lombokVersion |
| 35 | + |
| 36 | + /* Test annotation processors */ |
| 37 | + testAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: lombokVersion |
| 38 | + testAnnotationProcessor group: 'org.mapstruct', name: 'mapstruct-processor', version: mapStructVersion |
| 39 | + |
| 40 | + /* Test implementation dependencies */ |
| 41 | + testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBootVersion |
| 42 | + testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: springBootVersion |
| 43 | + testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: springBootVersion |
| 44 | + testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-mongodb', version: springBootVersion |
| 45 | + testImplementation group: 'org.springframework.security', name: 'spring-security-test', version: springSecurityVersion |
| 46 | + |
| 47 | + /* Test compile only dependencies */ |
| 48 | + testCompileOnly group: 'org.projectlombok', name: 'lombok', version: lombokVersion |
| 49 | + |
| 50 | +} |
| 51 | + |
| 52 | +def jacocoExcludePackages = ["**/reservationsApi/ReservationsApi.class", |
| 53 | + "**/reservationsApi/config/**", |
| 54 | + "**/reservationsApi/exception/*", |
| 55 | + "**/reservationsApi/model/*", |
| 56 | + "**/reservationsApi/security/*", |
| 57 | + "**/reservationsApi/web/advise/*", |
| 58 | + "**/reservationsApi/web/interceptor/*", |
| 59 | + "**/reservationsApi/web/request/*", |
| 60 | + "**/reservationsApi/web/response/*"] |
| 61 | + |
| 62 | +test { |
| 63 | + useJUnitPlatform() |
| 64 | + finalizedBy jacocoTestReport |
| 65 | +} |
| 66 | + |
| 67 | +jacoco { |
| 68 | + toolVersion "0.8.8" |
| 69 | +} |
| 70 | + |
| 71 | +jacocoTestReport { |
| 72 | + dependsOn test |
| 73 | + reports { |
| 74 | + xml.required = false |
| 75 | + csv.required = false |
| 76 | + } |
| 77 | + afterEvaluate { |
| 78 | + classDirectories.setFrom(files(classDirectories.files.collect { |
| 79 | + fileTree(dir: it, exclude: jacocoExcludePackages) |
| 80 | + })) |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +jacocoTestCoverageVerification { |
| 85 | + violationRules { |
| 86 | + rule { |
| 87 | + limit { |
| 88 | + minimum = 0.95 |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + afterEvaluate { |
| 93 | + classDirectories.setFrom(files(classDirectories.files.collect { |
| 94 | + fileTree(dir: it, exclude: jacocoExcludePackages) |
| 95 | + })) |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +check.dependsOn jacocoTestCoverageVerification |
0 commit comments