forked from MapJiri/mapjiri-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
167 lines (139 loc) · 4.99 KB
/
build.gradle
File metadata and controls
167 lines (139 loc) · 4.99 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
plugins {
id 'java'
id 'org.springframework.boot' version '3.4.2'
id 'io.spring.dependency-management' version '1.1.7'
id('com.epages.restdocs-api-spec') version '0.19.4'
id 'jacoco'
}
group = 'project'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
jacoco {
toolVersion = "0.8.12"
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
// CSV 파일 파싱
implementation 'org.apache.commons:commons-csv:1.10.0'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.security:spring-security-test'
// Spring Security
implementation 'org.springframework.boot:spring-boot-starter-security'
// JWT
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
// OpenAPI Specification
implementation 'org.springdoc:springdoc-openapi-ui:1.8.0'
testImplementation("com.epages:restdocs-api-spec-mockmvc:0.19.4")
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
implementation 'org.springframework.boot:spring-boot-starter-mail'
}
tasks.named('test') {
useJUnitPlatform()
finalizedBy('copyOasToSwagger') // test 태스크 실행 후에 copyOasToSwagger 태스크 실행
finalizedBy("jacocoTestReport") // test 태스크 실행 후에 jacocoTestReport 테스크 실행
}
openapi3 {
server = 'http://localhost:8080'
title = 'MAPJIRI API'
description = 'MAPJIRI API'
version = '0.0.1'
format = 'yaml'
}
tasks.register('copyOasToSwagger', Copy) {
// 기존 yaml 파일 삭제
delete 'src/main/resources/static/swagger-ui/openapi3.yaml'
// 복제할 yaml 파일 타겟팅
from layout.buildDirectory.file("api-spec/openapi3.yaml")
// 타겟 디렉토리로 파일 복제
into 'src/main/resources/static/swagger-ui'
// openapi3 task가 먼저 실행되도록 설정
dependsOn tasks.named('openapi3')
doFirst {
// 빌드디렉터리 yaml 파일에 보안 스키마 추가
def openapi3File = layout.buildDirectory.file("api-spec/openapi3.yaml").get().asFile
def securitySchemesContent = " securitySchemes:\n" + \
" JWT:\n" + \
" type: apiKey\n" + \
" name: Authorization\n" + \
" in: header\n" + \
"security:\n" +
" - JWT: [] "
// openapi 3.yaml 파일에 내용을 추가
if (openapi3File.exists()) {
openapi3File.append(securitySchemesContent)
} else {
println "Warning: openapi3.yaml not found at ${openapi3File.path}"
}
}
bootRun {
// openapi3 task가 먼저 실행되도록 설정
dependsOn 'openapi3'
}
}
def jacocoExclusions = [
"**/*Application*",
"**/dto/**",
"**/exception/**",
"**/config/**",
"**/generated/**" // lombok 자동 생성 파일
]
tasks.named('jacocoTestReport') {
dependsOn tasks.named('test')
reports {
xml.required.set(true)
html.required.set(true)
csv.required.set(false)
}
classDirectories.setFrom(
files(classDirectories.files.collect { dir ->
fileTree(dir) {
exclude jacocoExclusions
}
})
)
finalizedBy tasks.named('jacocoTestCoverageVerification') // 리포트 생성 후 검증 작업 진행
}
tasks.named('jacocoTestCoverageVerification') {
violationRules {
rule {
enabled = true
element = "BUNDLE"
limit {
counter = "INSTRUCTION"
value = "COVEREDRATIO"
minimum = 0.20 // 이후 0.80 내외 추천
}
limit {
counter = "BRANCH"
value = "COVEREDRATIO"
minimum = 0.20 // 이후 0.80 내외 추천
}
excludes = jacocoExclusions
}
}
}