@@ -3,6 +3,8 @@ plugins {
33 kotlin(" plugin.spring" ) version " 1.9.25"
44 id(" org.springframework.boot" ) version " 3.4.1"
55 id(" io.spring.dependency-management" ) version " 1.1.7"
6+ id(" jacoco" )
7+ id(" org.sonarqube" ) version " 6.0.1.5171"
68 kotlin(" plugin.jpa" ) version " 1.9.25"
79}
810
@@ -71,6 +73,90 @@ allOpen {
7173 annotation(" jakarta.persistence.Embeddable" )
7274}
7375
76+ jacoco {
77+ toolVersion = " 0.8.8"
78+ }
79+
7480tasks.withType<Test > {
7581 useJUnitPlatform()
82+ finalizedBy(tasks.jacocoTestReport)
83+ }
84+
85+ sonar {
86+ properties {
87+ property(" sonar.projectKey" , " YAPP-Github_25th-Web-Team-2-BE" )
88+ property(" sonar.organization" , " yapp-github" )
89+ property(" sonar.host.url" , " https://sonarcloud.io" )
90+ property(" sonar.coverage.jacoco.xmlReportPaths" , " build/reports/jacoco/index.xml" )
91+ property(" sonar.sources" , " src" )
92+ property(" sonar.language" , " kotlin" )
93+ property(" sonar.sourceEncoding" , " UTF-8" )
94+ property(" sonar.exclusions" , " **/test/**, **/resources/**, **/*Application*.kt, **/*Controller*.kt, **/*Config.kt'" +
95+ " , **/*Repository*.kt, **/*Dto*.kt, **/*Response*.kt, **/*Request*.kt, **/*Exception*.kt" )
96+ property(" sonar.test.inclusions" , " **/*Test.kt" )
97+ property(" sonar.kotlin.coveragePlugin" , " jacoco" )
98+ }
99+ }
100+
101+ tasks.jacocoTestReport {
102+ dependsOn(tasks.test)
103+ reports{
104+ html.required.set(true )
105+ xml.required.set(true )
106+ html.outputLocation.set(file(layout.buildDirectory.dir(" reports/jacoco/index.html" ).get().asFile))
107+ xml.outputLocation.set(file(layout.buildDirectory.dir(" reports/jacoco/index.xml" ).get().asFile))
108+ }
109+
110+ classDirectories.setFrom(
111+ files(
112+ classDirectories.files.flatMap { dir ->
113+ fileTree(dir) {
114+ exclude(
115+ " **/*Application*" ,
116+ " **/config/*" ,
117+ " **/domain/exception/*" ,
118+ " **/domain/gateway/*" ,
119+ " **/domain/model/*" ,
120+ " **/infrastructure/*" ,
121+ " **/presentation/*" ,
122+ " **/util/*"
123+ )
124+ }.files
125+ }
126+ )
127+ )
128+ finalizedBy(tasks.jacocoTestCoverageVerification)
129+ }
130+
131+ tasks.jacocoTestCoverageVerification {
132+ violationRules {
133+ rule {
134+ isFailOnViolation = false
135+ isEnabled = true
136+ element = " CLASS"
137+
138+ limit {
139+ counter = " LINE"
140+ value = " COVEREDRATIO"
141+ minimum = 0.70 .toBigDecimal()
142+ }
143+
144+ limit {
145+ counter = " BRANCH"
146+ value = " COVEREDRATIO"
147+ minimum = 0.70 .toBigDecimal()
148+ }
149+
150+ excludes = listOf (
151+ " **.*Application*" ,
152+ " **.config.*" ,
153+ " **.domain.exception.*" ,
154+ " **.domain.gateway.*" ,
155+ " **.domain.model.*" ,
156+ " **.infrastructure.*" ,
157+ " **.presentation.*" ,
158+ " **.util.*"
159+ )
160+ }
161+ }
76162}
0 commit comments