-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
246 lines (199 loc) · 6.49 KB
/
build.gradle
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
// 1. Import 추가
import org.hidetake.gradle.swagger.generator.GenerateSwaggerUI
buildscript {
ext {
restdocsApiSpecVersion = '0.17.1' // restdocsApiSpecVersion 버전 변수 설정
}
}
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.4'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
// epages-restdocs 플러그인 추가
id 'com.epages.restdocs-api-spec' version "${restdocsApiSpecVersion}"
//swagger generator 플러그인 추가
id 'org.hidetake.swagger.generator' version '2.18.2'
id 'jacoco'
}
group = 'ku-rum'
version = '0.0.1-SNAPSHOT'
jacoco {
toolVersion = "0.8.8"
reportsDirectory = layout.buildDirectory.dir('customJacocoReportDir')
}
test {
finalizedBy jacocoTestReport // test 작업이 끝나고 jacocoTestReport를 실행
}
jacocoTestReport {
dependsOn test // test 종속성 추가
reports {
xml.required = true
csv.required = false
html.required = true
}
def QDomainList = []
for (qPattern in '**/QA'..'**/QZ') { // QClass 대응
QDomainList.add(qPattern + '*')
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'**/dto/**',
'**/event/**',
'**/*InitData*',
'**/*Application*',
'**/exception/**',
'**/service/alarm/**',
'**/aop/**',
'**/config/**',
'**/MemberRole*',
'**/oauth/**'
] + QDomainList)
}))
}
finalizedBy 'jacocoTestCoverageVerification' // jacocoTestReport 태스크가 끝난 후 실행
}
jacocoTestCoverageVerification {
violationRules {
rule {
enabled = true
//코드 버커리지 체크 기준
element = 'CLASS'
limit {
counter = 'CLASS'
value = 'COVEREDRATIO'
minimum = 0.0
}
}
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
// 5. 생성된 API 스펙이 어느 위치에 있는지 지정
swaggerSources {
sample {
setInputFile(file("${project.buildDir}/api-spec/openapi3.yaml"))
}
}
// 6. openapi3 스펙 생성시 설정 정보
openapi3 {
servers = [
{ url = "https://kuroom.shop" },
{ url = "http://localhost:8080" }
]
title = "API 문서"
description = "RestDocsWithSwagger Docs"
version = "0.0.1"
format = "yaml"
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
runtimeOnly 'com.h2database:h2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
// redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
runtimeOnly 'com.mysql:mysql-connector-j'
// Mail Service
implementation 'org.springframework.boot:spring-boot-starter-mail'
// Spring Security
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.security:spring-security-test'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.2'
implementation 'org.seleniumhq.selenium:selenium-java:4.12.1'
implementation 'io.github.bonigarcia:webdrivermanager:5.7.0'
// Selenium Java
implementation 'org.seleniumhq.selenium:selenium-java:4.12.1'
// WebDriver Manager
implementation 'io.github.bonigarcia:webdrivermanager:5.7.0'
implementation 'org.jsoup:jsoup:1.15.3'
// Spring Batch
implementation 'org.springframework.boot:spring-boot-starter-batch'
implementation 'org.springframework.boot:spring-boot-starter-quartz'
testImplementation 'org.springframework.batch:spring-batch-test'
// JWT
implementation 'io.jsonwebtoken:jjwt-api:0.12.3'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.3'
// OAUTH
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
// JSOUP
implementation 'org.jsoup:jsoup:1.17.2'
// Spring REST Docs 의존성
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
// 8. openAPI3 추가
testImplementation 'com.epages:restdocs-api-spec-mockmvc:' + restdocsApiSpecVersion
// 9. SwaggerUI 추가
swaggerUI 'org.webjars:swagger-ui:4.11.1'
// 10. Assertj 추가
testImplementation 'org.assertj:assertj-core:3.23.1'
// Testcontainers & Selenium
testImplementation 'org.testcontainers:junit-jupiter'
testImplementation 'org.testcontainers:selenium'
//FireBase
implementation 'com.google.firebase:firebase-admin:6.8.1'
//actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator'
//micrometer
implementation 'io.micrometer:micrometer-registry-prometheus'
// AWS
implementation 'io.awspring.cloud:spring-cloud-starter-aws:2.4.4'
implementation 'io.awspring.cloud:spring-cloud-starter-aws-secrets-manager-config:2.4.4'
}
tasks.named('test') {
useJUnitPlatform()
}
tasks.named('jar') {
enabled = false
}
// 10. openapi3가 먼저 실행
tasks.withType(GenerateSwaggerUI) {
dependsOn 'openapi3'
doFirst {
def swaggerUIFile = file("${openapi3.outputDirectory}/openapi3.yaml")
def securitySchemesContent = " securitySchemes:\n" + \
" APIKey:\n" + \
" type: apiKey\n" + \
" name: Authorization\n" + \
" in: header\n" + \
"security:\n" +
" - APIKey: [] # Apply the security scheme here"
swaggerUIFile.append securitySchemesContent
}
}
def querydslSrcDir = 'src/main/generated'
clean {
delete file(querydslSrcDir)
}
//tasks.register("copySwaggerDocs", Copy) {
// dependsOn generateSwaggerUISample
// from("${generateSwaggerUISample.outputDir}")
// into("${project.projectDir}/src/main/resources/static/docs")
//}
// 11. 생성된 openapi3 스펙을 기반으로 SwaggerUISample 생성 및 static/docs 패키지에 복사
bootJar {
dependsOn generateSwaggerUISample
from("${generateSwaggerUISample.outputDir}") {
into 'static/docs'
}
}