Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ plugins {
id 'org.springframework.boot' version '3.3.5'
id 'io.spring.dependency-management' version '1.1.6'
id "org.sonarqube" version "5.1.0.4882"
id "jacoco"
}




group = 'com'
version = '0.0.1-SNAPSHOT'

Expand All @@ -24,12 +28,73 @@ repositories {
mavenCentral()
}

jacoco {
toolVersion = "0.8.12"
}

//QueryDSL ์ œ์™ธ ํŒจํ„ด
def QDomains = []
for (qPattern in '*.QA'..'*.QZ') { // qPattern = '*.QA', '*.QB', ... '*.QZ'
QDomains.add(qPattern + '*')
}

def jacocoExcludePatterns = [
// ์ธก์ • ์•ˆํ•˜๊ณ  ์‹ถ์€ ํŒจํ„ด
"**/*Application*",
"**/*Config*",
"**/*Exception*",
"**/*Request*",
"**/*Response*",
"**/*Dto*",
"**/*Interceptor*",
"**/*Filter*",
"**/*Resolver*",
"**/*Entity*",
"**/test/**",
"**/resources/**"
]

jacocoTestCoverageVerification {

violationRules {
rule {
// rule ํ™œ์„ฑํ™”
enabled = true

// ํด๋ž˜์Šค ๋‹จ์œ„๋กœ ๋ฃฐ ์ฒดํฌ
element = 'CLASS'

// ๋ผ์ธ ์ปค๋ฒ„๋ฆฌ์ง€๋ฅผ ์ตœ์†Œ 80% ๋งŒ์กฑ
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.60
}

// ๋ธŒ๋žœ์น˜ ์ปค๋ฒ„๋ฆฌ์ง€๋ฅผ ์ตœ์†Œ 80% ๋งŒ์กฑ
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.60
}

excludes = jacocoExcludePatterns
}
}
}


sonar {
properties {
property "sonar.projectKey", "prgrms-web-devcourse-final-project_WEB1_1_Bongdari_BE"
property "sonar.organization", "prgrms-web-devcourse-final-project"
property "sonar.host.url", "https://sonarcloud.io"
property 'sonar.sources', 'src'
property 'sonar.language', 'java'
property 'sonar.test.exclusions', jacocoExcludePatterns.join(',')
property 'sonar.test.inclusions', '**/*Test.java'
property 'sonar.java.coveragePlugin', 'jacoco'
property 'sonar.coverage.jacoco.xmlReportPaths', jacocoDir.get().file("jacoco/index.xml").asFile
}
}

Expand Down Expand Up @@ -64,4 +129,29 @@ dependencies {

tasks.named('test') {
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
}

def jacocoDir = layout.buildDirectory.dir("reports/")

jacocoTestReport {
dependsOn test // ํ…Œ์ŠคํŠธ๊ฐ€ ์ˆ˜ํ–‰๋˜์–ด์•ผ๋งŒ report๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •
reports {
html.required.set(true)
xml.required.set(true)
csv.required.set(true)
html.destination jacocoDir.get().file("jacoco/index.html").asFile
xml.destination jacocoDir.get().file("jacoco/index.xml").asFile
csv.destination jacocoDir.get().file("jacoco/index.csv").asFile
}

afterEvaluate {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, excludes: jacocoExcludePatterns + QDomains) // Querydsl ๊ด€๋ จ ์ œ๊ฑฐ
})
)
}
finalizedBy jacocoTestCoverageVerification

}
Loading