Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
177 lines (149 loc) · 6.85 KB
/
Copy pathbuild.gradle
File metadata and controls
177 lines (149 loc) · 6.85 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
plugins {
id 'java-library'
id 'org.springframework.boot'
id 'io.spring.dependency-management'
id 'com.epages.restdocs-api-spec'
}
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
}
}
group = "${projectGroup}"
version = "${applicationVersion}"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(project.javaVersion)
}
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies {
// ============== Spring Boot Starters ==============
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-restclient'
// ============== Database & Persistence ==============
// MySQL
runtimeOnly 'com.mysql:mysql-connector-j'
// QueryDSL
implementation 'com.querydsl:querydsl-jpa::jakarta'
annotationProcessor 'com.querydsl:querydsl-apt::jakarta'
annotationProcessor 'jakarta.annotation:jakarta.annotation-api'
annotationProcessor 'jakarta.persistence:jakarta.persistence-api'
// SQL Logging (P6Spy)
implementation "p6spy:p6spy:${p6spyVersion}"
implementation "com.github.gavlyukovskiy:datasource-decorator-spring-boot-autoconfigure:${datasourceDecoratorVersion}"
// ============== Security & JWT ==============
// JWT
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: "${jjwtVersion}"
implementation group: 'io.jsonwebtoken', name: 'jjwt-impl', version: "${jjwtVersion}"
implementation group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: "${jjwtVersion}"
// Apple Login
implementation 'com.nimbusds:nimbus-jose-jwt:3.10'
// ============== Utils & Libraries ==============
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// JSON
implementation "com.googlecode.json-simple:json-simple:${jsonSimpleVersion}"
// 구조화 로깅
runtimeOnly "net.logstash.logback:logstash-logback-encoder:${logstashLogbackEncoderVersion}"
// ============== External Services ==============
// FCM (Firebase Cloud Messaging)
implementation "com.google.firebase:firebase-admin:${firebaseAdminVersion}"
// S3 Mapping Library
api "com.github.Team-WSS:WSS-Server-S3:${wssS3Version}"
// Swagger UI (WebJar로 번들을 직접 제공한다. API 명세는 REST Docs 산출물만 사용한다)
implementation "org.webjars:swagger-ui:${swaggerUiVersion}"
implementation 'org.webjars:webjars-locator-lite'
// ============== Test ==============
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test'
testImplementation 'org.springframework.boot:spring-boot-starter-security-test'
testRuntimeOnly 'com.h2database:h2'
// REST Docs (문서 테스트 결과를 OpenAPI 3 명세로 변환)
testImplementation 'org.springframework.boot:spring-boot-starter-restdocs'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation "com.epages:restdocs-api-spec-mockmvc:${restdocsApiSpecVersion}"
}
tasks.named('test') {
useJUnitPlatform()
}
// ============== API 문서 (Spring REST Docs -> OpenAPI 3) ==============
// 문서 산출물은 모두 build 디렉터리 안에서만 생성하고 Git으로 추적하지 않는다.
ext {
restDocsSnippetsDir = layout.buildDirectory.dir('generated-snippets')
openApiSpecDir = layout.buildDirectory.dir('api-spec')
// Swagger UI가 classpath:/swagger-ui/openapi3.json 으로 읽도록 리소스 형태로 담아 두는 디렉터리.
openApiResourcesDir = layout.buildDirectory.dir('api-docs-resources')
openApiSwaggerUiDir = layout.buildDirectory.dir('api-docs-resources/swagger-ui')
}
openapi3 {
// 명세를 제공하는 origin을 그대로 쓰도록 상대 URL로 둔다.
server = '/'
title = 'WSS-Server API'
description = 'Spring REST Docs 문서 테스트로 생성한 OpenAPI 3 명세'
version = "${applicationVersion}"
format = 'json'
snippetsDirectory = 'build/generated-snippets'
outputDirectory = 'build/api-spec'
outputFileNamePrefix = 'openapi3'
}
// 문서 테스트가 실패했을 때 이전 실행의 snippet과 명세가 남아 성공으로 오인되지 않도록 생성 전에 지운다.
tasks.register('cleanApiSpec', Delete) {
delete restDocsSnippetsDir, openApiSpecDir, openApiResourcesDir
}
// 명세 생성은 MockMvc 문서 테스트(*DocsTest)에만 의존한다.
// 전체 test task에 의존하면 외부 DB, Redis가 필요한 통합 테스트까지 통과해야 명세를 만들 수 있다.
tasks.register('restDocsTest', Test) {
group = 'verification'
description = 'REST Docs 문서 테스트(*DocsTest)만 실행한다'
useJUnitPlatform()
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
filter {
includeTestsMatching '*DocsTest'
}
// snippet 디렉터리를 출력으로 선언해, 산출물이 지워지면 UP-TO-DATE로 건너뛰지 않게 한다.
outputs.dir restDocsSnippetsDir
mustRunAfter tasks.named('cleanApiSpec')
}
// openapi3 task는 restdocs-api-spec 플러그인이 프로젝트 평가 이후에 등록하고 check에 의존하게 만든다.
// 전체 테스트(check) 대신 문서 테스트에만 의존하도록 평가 이후에 의존 관계를 교체한다.
afterEvaluate {
tasks.named('openapi3') {
setDependsOn([tasks.named('cleanApiSpec'), tasks.named('restDocsTest')])
}
}
tasks.register('apiDocs', Copy) {
group = 'documentation'
description = 'REST Docs 문서 테스트를 실행하고 OpenAPI 3 명세를 생성한다'
dependsOn 'openapi3'
from openApiSpecDir
into openApiSwaggerUiDir
}
// apiDocs를 함께 실행하면 생성된 명세를 classpath:/swagger-ui 로 패키징한다.
// apiDocs 없이 빌드하면 명세가 없는 상태로 패키징되고, 이전 실행의 명세가 섞이지 않는다.
tasks.named('bootJar') {
mustRunAfter tasks.named('apiDocs')
from(openApiResourcesDir) {
into 'BOOT-INF/classes'
}
}
// 로컬에서 bootRun으로 Swagger UI를 확인할 때도 생성된 명세를 classpath에서 읽게 한다.
tasks.named('bootRun') {
mustRunAfter tasks.named('apiDocs')
classpath += files(openApiResourcesDir)
}