-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
94 lines (80 loc) · 2.88 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
plugins {
jacoco
id("application")
java
id("org.springframework.boot") version "3.2.3" apply false
id("io.spring.dependency-management") version "1.1.4"
id("org.sonarqube") version "5.0.0.4638"
}
group = "com.qa.blog"
version = "1.0.0"
description = "Kata"
java {
sourceCompatibility = JavaVersion.VERSION_21
}
repositories {
mavenCentral()
}
tasks.register<JacocoReport>("codeCoverageReport") {
group = "Coverage"
description = "Coverage report aggregation"
// If a subproject applies the 'jacoco' plugin, add the result it to the report
subprojects {
val subproject = this
subproject.plugins.withType<JacocoPlugin>().configureEach {
subproject.tasks.matching({ it.extensions.findByType<JacocoTaskExtension>() != null }).configureEach {
val testTask = this
sourceSets(subproject.sourceSets.main.get())
executionData(testTask)
}
// To automatically run `test` every time `./gradlew codeCoverageReport` is called,
// you may want to set up a task dependency between them as shown below.
// Note that this requires the `test` tasks to be resolved eagerly (see `forEach`) which
// may have a negative effect on the configuration time of your build.
subproject.tasks.matching({ it.extensions.findByType<JacocoTaskExtension>() != null }).forEach {
rootProject.tasks["codeCoverageReport"].dependsOn(it)
}
}
}
// enable the different report types (html, xml, csv)
reports {
// xml is usually used to integrate code coverage with
// other tools like SonarQube, Coveralls or Codecov
xml.required = true
// HTML reports can be used to see code coverage
// without any external tools
html.required = true
}
}
subprojects {
repositories {
mavenCentral()
}
apply {
plugin("jacoco")
plugin("application")
plugin("java")
plugin("io.spring.dependency-management")
}
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:3.2.3")
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
}
tasks.check {
dependsOn(tasks.named<JacocoReport>("codeCoverageReport"))
}
sonar {
properties {
property("sonar.projectKey", "blog")
property("sonar.projectName", "Blog")
property("sonar.exclusions", "**/BlogApplication.java,**/ApplicationConfig.java,**/build.gradle.kts")
property("sonar.coverage.exclusions", "**/ApplicationConfig.java,**/BlogApplication.java,**/build.gradle.kts")
property("sonar.coverage.jacoco.xmlReportPaths", "${project.projectDir}/build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml")
property ("sonar.gradle.skipCompile", "true")
}
}