-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
352 lines (292 loc) · 10.5 KB
/
build.gradle
File metadata and controls
352 lines (292 loc) · 10.5 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
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
import org.hidetake.gradle.swagger.generator.GenerateSwaggerUI
plugins {
id 'java'
id 'org.springframework.boot' version '3.4.0'
id 'io.spring.dependency-management' version '1.1.6'
id 'jacoco' // JaCoCo 플러그인
id 'com.epages.restdocs-api-spec' version '0.19.2' // openAPI 플러그인
id 'org.hidetake.swagger.generator' version '2.19.2' // swaggerUI 플러그인
id 'org.sonarqube' version '6.0.1.5171' // SonarQube 플러그인
}
group = 'org.programmers'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
configurations.configureEach {
exclude group: 'commons-logging', module: 'commons-logging'
}
repositories {
mavenCentral()
}
dependencies {
// Web
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'org.springframework.boot:spring-boot-starter-mail'
// Lombok
annotationProcessor 'org.projectlombok:lombok'
compileOnly 'org.projectlombok:lombok'
// DB
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
// Scheduling Lock
implementation 'net.javacrumbs.shedlock:shedlock-spring:6.2.0'
implementation 'net.javacrumbs.shedlock:shedlock-provider-redis-spring:6.2.0'
// Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.springframework.boot:spring-boot-testcontainers'
testImplementation 'org.testcontainers:testcontainers:2.0.3'
testImplementation 'org.testcontainers:junit-jupiter:1.21.4'
testImplementation 'org.testcontainers:mariadb:1.21.4'
// Hibernate-spatial
implementation 'org.hibernate:hibernate-spatial:6.6.3.Final'
// Hibernate-util
implementation 'io.hypersistence:hypersistence-utils-hibernate-63:3.9.2'
// Mapstuct
implementation 'org.mapstruct:mapstruct:1.6.3'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.6.3'
// QueryDSL
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"
// Thymeleaf
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
// Batch
implementation 'org.springframework.boot:spring-boot-starter-batch'
testImplementation 'org.springframework.batch:spring-batch-test'
// Security
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
// Monitoring
implementation 'org.springframework.boot:spring-boot-starter-actuator'
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
// Amazon S3
implementation 'software.amazon.awssdk:s3:2.30.3'
// Swagger + REST Docs
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'com.epages:restdocs-api-spec-mockmvc:0.19.4'
swaggerUI 'org.webjars:swagger-ui:3.52.5'
// 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'
//openCsv
implementation 'com.opencsv:opencsv:5.7.1' // 최신 버전 확인 후 적절한 버전 사용
// MockWebServer
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
// FireBase Admin SDK
implementation 'com.google.firebase:firebase-admin:9.4.3'
// Apache poi
implementation 'org.apache.poi:poi-ooxml:5.2.3'
// Log
implementation 'net.logstash.logback:logstash-logback-encoder:8.0'
// Xml
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.19.0-rc2"
}
// JaCoCo 버전 설정
jacoco {
toolVersion = '0.8.12'
}
// QClass 패턴
def QDomains = []
for (qPattern in '*.QA'..'*.QZ') { // qPattern = '*.QA', '*.QB', ... '*.QZ'
QDomains.add(qPattern + '*')
}
// MapStruct 패턴
def MapStruct = [
"*.*Mapper*"
]
// 측정 안하고 싶은 패턴
def jacocoExcludePatterns = [
"*.*Application*",
"**/*Application*",
"*.*Config*",
"*.*Exception*",
"*.*ErrorCode*",
"*.*Request*",
"*.*Response*",
"*.*Interceptor*",
"**/Interceptor*",
"*.*Filter*",
"**/*Filter*",
"*.*Handler*",
"**/*Handler*",
"*.*Resolver*",
"**/*Resolver*",
"*.*DataInitializer*",
"*.*RestDocsFormatGenerators*",
"*.dto.*",
"**/dto/**",
"*.config.*",
"**/config/**",
"*.entity.*",
"**/entity/**",
"*.exception.*",
"**/exception/**",
"*.repository.*",
"**/repository/**",
"*.util.*",
"**/util/**",
"*.test.*",
"**/test/**",
"*.resources.*",
"**/resources/**"
]
// 코드 커버리지 기준 설정
jacocoTestCoverageVerification {
violationRules {
rule {
// Rule 활성화
enabled = true
// 클래스 단위로 체크
element = 'CLASS'
// 라인 커버리지 기준
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.00 // 커버리지 기준 20% 이상
}
// 브랜치 커버리지 기
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.00 // 커버리지 기준 20% 이상
}
excludes = jacocoExcludePatterns + QDomains + MapStruct
}
}
}
def jacocoDir = layout.buildDirectory.dir("reports/")
// 결과 리포트 설정
jacocoTestReport {
dependsOn test // 테스트가 수행되어야만 리포트를 생성할 수 있도록 설정
reports {
// 원하는 리포트를 켜고 끌 수 있습니다.
html.required.set(true)
xml.required.set(true)
csv.required.set(false)
// 리포트 생성 위치
html.destination jacocoDir.get().file("jacoco/index.html").asFile
xml.destination jacocoDir.get().file("jacoco/index.xml").asFile
}
finalizedBy jacocoTestCoverageVerification
}
tasks.named('test') {
systemProperty('spring.profiles.active', 'test')
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
}
// 서브 모듈에 있는 config 파일들을 resources로 복사
task copyConfig(type: Copy) {
copy {
from './submodule/config'
into 'src/main/resources'
}
// firebase 관련 파일 복사
copy {
from './submodule/firebase'
into 'src/main/resources/firebase'
}
}
// Querydsl 빌드 옵션 (옵셔널)
def generated = 'src/main/generated'
// querydsl QClass 파일 생성 위치를 지정
tasks.withType(JavaCompile) {
options.getGeneratedSourceOutputDirectory().set(file(generated))
}
// java source set 에 querydsl QClass 위치 추가
sourceSets {
main.java.srcDirs += [ generated ]
}
// gradle clean 시에 QClass 디렉토리 삭제
clean {
delete file(generated)
}
swaggerSources {
sample {
setInputFile(file("${buildDir}/api-spec/openapi3.yaml"))
}
}
// openapi 작업 추가
openapi3 {
servers = [
{
url = "https://52.79.71.9.nip.io"
description = "Develop Server"
},
{
url = "http://localhost:8080"
description = "Local Server"
}
]
title = "Signal Buddy API 문서"
description = "Signal Buddy API Docs"
version = "0.0.1"
format = "yaml"
}
// openapi3가 먼저 실행 - doFirst를 통한 Header 설정
tasks.withType(GenerateSwaggerUI) {
dependsOn 'openapi3'
doFirst {
def swaggerUIFile = file("${openapi3.outputDirectory}/openapi3.yaml")
def securitySchemesContent = " securitySchemes:\n" + \
" bearerAuth:\n" + \
" type: http\n" + \
" scheme: bearer\n" + \
" bearerFormat: JWT\n" + \
" name: Authorization\n" + \
" in: header\n" + \
" description: \"Use 'your-access-token' as the value of the Authorization header\"\n" + \
"security:\n" +
" - bearerAuth: [] # Apply the security scheme here"
swaggerUIFile.append securitySchemesContent
}
}
tasks.register('copyDocument', Copy) {
dependsOn generateSwaggerUISample
from file("build/swagger-ui-sample/")
into file("src/main/resources/static/docs")
}
tasks.register('copyOasToDocs', Copy) {
dependsOn copyDocument
from file("build/api-spec")
into file("src/main/resources/static/docs")
}
bootJar {
dependsOn copyOasToDocs
from("src/main/resources/static/docs") {
into "static/docs" // JAR 내부에서 접근할 경로
}
}
// SonarQube 설정
sonar {
properties {
property "sonar.projectKey", "prgrms-web-devcourse-final-project_WEB2_3_SIGNAL-BUDDY_BE"
property "sonar.organization", "prgrms-web-devcourse-final-project"
property "sonar.host.url", "https://sonarcloud.io"
property 'sonar.sources', 'src/main/java'
property 'sonar.tests', 'src/test/java'
property 'sonar.language', 'java'
property 'sonar.sourceEncoding', 'UTF-8'
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
}
}