-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
198 lines (169 loc) · 6.06 KB
/
build.gradle
File metadata and controls
198 lines (169 loc) · 6.06 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
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.2' // 3.5.7은 존재하지 않아 안정적인 최신 버전으로 수정했습니다.
id 'io.spring.dependency-management' version '1.1.7'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'com.epages.restdocs-api-spec' version '0.19.2'
id 'nu.studer.jooq' version '9.0' // jOOQ 코드 생성을 위한 플러그인
}
group = 'wonjun'
version = '0.0.1-SNAPSHOT'
description = 'Demo project for Spring Boot'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
asciidoctorExt
}
repositories {
mavenCentral()
}
ext {
snippetsDir = file('build/generated-snippets')
// [중요] jOOQ 버전을 변수로 관리합니다. (Spring Boot 3.2.x와 호환되는 3.18.x 사용)
jooqVersion = '3.18.9'
}
dependencies {
// [변경] JPA 제거 -> jOOQ 추가
// implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jooq'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
// [추가] Flyway (DB 마이그레이션)
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-mysql'
// [중요] jOOQ Generator가 SQL 파일을 파싱하기 위한 라이브러리 (버전 명시 필수)
jooqGenerator "org.jooq:jooq-meta-extensions:${jooqVersion}"
// Java 17 이상에서 XML 파싱 에러 방지를 위해 필요
jooqGenerator 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
// Swagger UI
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
// Security
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.security:spring-security-test'
// OAuth2 Client
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
// JWT
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
// Test dependencies
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'com.epages:restdocs-api-spec-mockmvc:0.19.2'
testImplementation 'org.testcontainers:testcontainers:1.19.3'
testImplementation 'org.testcontainers:mysql:1.19.3'
testImplementation 'org.testcontainers:junit-jupiter:1.19.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
// AsciiDoctor extension for REST Docs
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
// Redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
}
// [핵심] jOOQ 설정: DB 연결 없이 SQL 파일만 보고 코드 생성
jooq {
version = jooqVersion // 위에서 정의한 변수 사용
configurations {
main {
generationTool {
logging = org.jooq.meta.jaxb.Logging.WARN
generator {
name = 'org.jooq.codegen.DefaultGenerator'
database {
// 실제 DB 연결 대신 DDL 파일(SQL)을 파싱하는 방식
name = 'org.jooq.meta.extensions.ddl.DDLDatabase'
properties {
property {
// Flyway SQL 파일들이 있는 경로
key = 'scripts'
value = 'src/main/resources/db/migration'
}
property {
// 파일 읽는 순서 (V1, V2...)
key = 'sort'
value = 'flyway'
}
property {
key = 'defaultNameCase'
value = 'lower'
}
}
}
target {
// 생성될 패키지명
packageName = 'wonjun.stiky.generated'
// 생성될 경로
directory = 'build/generated-src/jooq/main'
}
}
}
}
}
}
// 1. 테스트 설정
tasks.named('test') {
outputs.dir snippetsDir
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
showStandardStreams = true
exceptionFormat = "full"
}
}
// 2. OpenAPI 스펙 생성 설정
openapi3 {
server = 'https://stiky-api-mh6lf6mzkq-du.a.run.app'
title = 'Stiky API'
description = 'Stiky API 명세서'
version = '1.0.0'
format = 'yaml'
outputDirectory = 'build/api-spec'
}
// 3. AsciiDoctor 설정
asciidoctor {
inputs.dir snippetsDir
configurations 'asciidoctorExt'
dependsOn test
baseDirFollowsSourceFile()
}
// 4. 문서 복사 태스크
task copyDocument(type: Copy) {
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/static/docs")
}
task copyOasToSwagger(type: Copy) {
dependsOn 'openapi3'
from "build/api-spec/openapi3.yaml"
into "src/main/resources/static/docs"
}
// 플러그인 로드 순서 문제 해결을 위한 설정
afterEvaluate {
tasks.named('openapi3') {
dependsOn 'test'
}
}
// 5. 빌드 및 패키징
build {
dependsOn copyDocument
dependsOn copyOasToSwagger
}
bootJar {
dependsOn copyDocument
dependsOn copyOasToSwagger
from("${asciidoctor.outputDir}") {
into 'static/docs'
}
from("src/main/resources/static/docs") {
include 'openapi3.yaml'
into 'static/docs'
}
}