-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
169 lines (134 loc) · 5.58 KB
/
Copy pathbuild.gradle
File metadata and controls
169 lines (134 loc) · 5.58 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
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' // Asciidoctor 플러그인
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
snippetsDir = file("build/generated-snippets") // REST Docs에서 생성된 스니펫 디렉토리
}
tasks.register('prepareDocs') {
doLast {
def snippetsDir = file('build/generated-snippets')
def indexFile = file('src/docs/asciidoc/index.adoc')
// 하위 디렉토리까지 포함하여 .adoc 파일을 찾는 방법
def snippetFiles = findAdocFiles(snippetsDir)
if (snippetFiles.isEmpty()) {
throw new GradleException("No snippets found in ${snippetsDir}")
}
// 재귀적으로 .adoc 파일을 찾는 함수
// `include` 구문 생성, 상대 경로를 올바르게 얻기 위한 수정
def snippetIncludes = snippetFiles.collect { file ->
// 상대 경로 계산: snippetsDir을 기준으로 상대 경로를 계산
def relativePath = snippetsDir.toPath().relativize(file.toPath()).toString()
// Windows에서 발생할 수 있는 경로 구분자 문제 해결
def cleanedPath = relativePath.replace("\\", "/")
// `snippets` 변수와 함께 `include` 구문 생성
"include::{snippets}/${cleanedPath}[]"
}
// 최종 index.adoc 내용 작성
def indexContent = """
= 프로젝트 REST Docs
Author Name <author@example.com>
:toc: left
:doctype: book
:source-highlighter: coderay
:snippets: build/generated-snippets
== API 목록
${snippetIncludes.join('\n')}
"""
// 파일을 UTF-8 인코딩으로 작성
indexFile.withWriter('UTF-8') { writer ->
writer.write(indexContent)
}
println "Updated ${indexFile} with snippet includes."
}
}
// 재귀적으로 .adoc 파일을 찾는 함수
def findAdocFiles(File dir) {
def files = []
dir.eachFileRecurse { file ->
if (file.name.endsWith('.adoc')) {
files << file
}
}
return files
}
asciidoctor {
dependsOn prepareDocs
inputs.dir snippetsDir
attributes 'snippets': snippetsDir
dependsOn test
sourceDir = file('src/docs/asciidoc')
outputDir = file("build/docs/html")
attributes 'source-highlighter': 'coderay', 'charset': 'UTF-8'
}
task generateDocs(type: Copy) {
dependsOn asciidoctor // asciidoctor 태스크 후에 실행
from 'build/docs/html' // AsciiDoc으로 변환된 HTML 파일의 위치
into 'build/docs' // 출력할 디렉토리
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
implementation 'org.mapstruct:mapstruct:1.5.5.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
runtimeOnly 'com.mysql:mysql-connector-j'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'io.jsonwebtoken:jjwt-api:0.12.2'
implementation 'io.jsonwebtoken:jjwt-impl:0.12.2'
implementation 'io.jsonwebtoken:jjwt-jackson:0.12.2'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
//s3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
implementation 'org.bouncycastle:bcpkix-jdk18on:1.72'
implementation 'commons-io:commons-io:2.11.0'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.2'
//jasypt
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5'
testImplementation 'org.jasypt:jasypt:1.9.3' // Jasypt 의존성 (테스트용)
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.squareup.okhttp3:okhttp:4.10.0' // HTTP 요청 라이브러리
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2' // JSON 처리
testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.11.0'
//rest docs 관련
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.springframework.restdocs:spring-restdocs-core'
}
tasks.test {
useJUnitPlatform() // JUnit 5 플랫폼 사용
}
processResources.dependsOn('copySecret')
tasks.register('copySecret', Copy) {
from './config' // 서브 모듈 디렉토리 경로
include "*.yml" // 설정 파일 복사
into 'src/main/resources' // 붙여넣을 위치
}