-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
290 lines (252 loc) · 9.43 KB
/
Copy pathbuild.gradle
File metadata and controls
290 lines (252 loc) · 9.43 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
import org.springframework.boot.gradle.tasks.bundling.BootJar
plugins {
alias(libs.plugins.spring.boot) apply false
alias(libs.plugins.spotless) apply false
alias(libs.plugins.hibernate.orm) apply false
alias(libs.plugins.dependency.graph.generator)
}
group = "com.icc.qasker"
version = "3.7.2"
subprojects {
tasks.configureEach { task ->
if (task.name == "compileJava") {
task.dependsOn(rootProject.tasks.named("installGitHooks"))
}
}
dependencyLocking {
lockAllConfigurations()
}
tasks.register("resolveAndLockAll") {
notCompatibleWithConfigurationCache("Filters configurations at execution time")
doFirst {
assert gradle.startParameter.writeDependencyLocks: "--write-locks 플래그와 함께 실행하세요"
}
doLast {
configurations.findAll { it.canBeResolved }*.resolve()
}
}
apply plugin: 'java'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
dependencies {
implementation platform(libs.spring.boot.bom)
annotationProcessor platform(libs.spring.boot.bom)
implementation platform(libs.spring.ai.bom)
implementation platform(libs.google.cloud.bom)
compileOnly "org.projectlombok:lombok"
annotationProcessor "org.projectlombok:lombok"
implementation "org.springframework.boot:spring-boot-starter-validation"
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
apply plugin: 'com.diffplug.spotless'
spotless {
java {
googleJavaFormat(libs.versions.google.java.format.get())
removeUnusedImports()
endWithNewline()
trimTrailingWhitespace()
}
}
configurations.configureEach {
resolutionStrategy.eachDependency {
if (it.requested.group == 'org.hibernate.orm') {
it.useVersion(libs.versions.hibernate.orm.get())
}
}
}
apply plugin: 'org.hibernate.orm'
if (project.path == ':quiz-set-impl' && !project.hasProperty('disableHibernateEnhancement')) {
hibernate {
enhancement {}
}
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
testLogging {
showStandardStreams = true
}
if (project.hasProperty('testMaxHeap')) {
maxHeapSize = project.property('testMaxHeap')
}
if (project.hasProperty('testMinHeap')) {
minHeapSize = project.property('testMinHeap')
}
if (project.hasProperty('testGcLog')) {
jvmArgs += ['-Xlog:gc*:stdout:time,level,tags']
}
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += '-parameters'
}
tasks.withType(Jar).configureEach {
duplicatesStrategy = DuplicatesStrategy.FAIL
}
tasks.withType(BootJar).configureEach {
duplicatesStrategy = DuplicatesStrategy.FAIL
}
}
tasks.register("installGitHooks") {
description = "Git hooks 경로를 .githooks/로 설정"
group = "setup"
doLast {
exec {
commandLine("git", "config", "core.hooksPath", ".githooks")
}
logger.lifecycle("✅ Git hooks 경로가 .githooks/로 설정되었습니다.")
}
}
tasks.register("dependencyGraphStyled") {
dependsOn("generateProjectDependencyGraph")
group = "reporting"
description = "스타일이 적용된 모듈 의존성 그래프를 생성합니다"
def inputDir = file("build/reports/project-dependency-graph")
def outputDir = file("build/reports/dependency-graph-styled")
doLast {
def dotFile = new File(inputDir, "project-dependency-graph.dot")
if (!dotFile.exists()) {
throw new GradleException("DOT 파일이 없습니다: ${dotFile}")
}
outputDir.mkdirs()
def dotContent = dotFile.text
def edges = []
def nodes = [] as Set
dotContent.eachLine { line ->
line = line.trim()
def edgeMatcher = line =~ /^"([^"]+)"\s*->\s*"([^"]+)"(.*)$/
if (edgeMatcher.matches()) {
def from = edgeMatcher[0][1]
def to = edgeMatcher[0][2]
def attrs = edgeMatcher[0][3]?.trim() ?: ""
nodes << from
nodes << to
edges << [from: from, to: to, attrs: attrs]
}
def nodeMatcher = line =~ /^"([^"]+)"\s*\[.*$/
if (nodeMatcher.matches() && !line.contains("->")) {
nodes << nodeMatcher[0][1]
}
}
def implNodes = nodes.findAll { it.endsWith("-impl") }
def apiNodes = nodes.findAll { it.endsWith("-api") }
def appNode = nodes.find { it == ":app" }
def globalNode = nodes.find { it == ":global" }
def appToImpl = edges.findAll { it.from == ":app" && it.to.endsWith("-impl") }
def implToOwnApi = edges.findAll { e ->
e.from.endsWith("-impl") && e.to.endsWith("-api") &&
e.from.replace("-impl", "") == e.to.replace("-api", "")
}
def crossDeps = edges.findAll { e ->
e.from.endsWith("-impl") && e.to.endsWith("-api") &&
e.from.replace("-impl", "") != e.to.replace("-api", "")
}
def apiToApi = edges.findAll { e ->
e.from.endsWith("-api") && e.to.endsWith("-api")
}
def toGlobal = edges.findAll { e ->
e.to == ":global" && !e.from.endsWith("-api")
}
def apiToGlobal = edges.findAll { e ->
e.to == ":global" && e.from.endsWith("-api")
}
def styled = new StringBuilder()
styled.append("""digraph {
graph [
dpi="100"
label="${rootProject.name} Module Dependency Graph"
labelloc="t"
fontsize="28"
fontname="Helvetica Neue"
bgcolor="#FAFAFA"
pad="0.8"
nodesep="1.0"
ranksep="1.5"
rankdir="TB"
splines="polyline"
]
node [
style="filled,rounded"
shape="box"
fontname="Helvetica Neue"
fontsize="14"
penwidth="1.5"
margin="0.25,0.12"
]
edge [
dir="forward"
color="#90A4AE"
penwidth="1.2"
arrowsize="0.7"
]
""")
if (appNode) {
styled.append(""" "${appNode}" [label="app" fillcolor="#1A237E" fontcolor="white" pencolor="#0D47A1" fontsize="16"]\n""")
}
implNodes.sort().each { n ->
def label = n.replaceFirst(":", "")
styled.append(""" "${n}" [label="${label}" fillcolor="#42A5F5" fontcolor="white" pencolor="#1E88E5"]\n""")
}
apiNodes.sort().each { n ->
def label = n.replaceFirst(":", "")
styled.append(""" "${n}" [label="${label}" fillcolor="#A5D6A7" fontcolor="#1B5E20" pencolor="#66BB6A"]\n""")
}
if (globalNode) {
styled.append(""" "${globalNode}" [label="global" fillcolor="#FFB74D" fontcolor="#E65100" pencolor="#FFA726" fontsize="16"]\n""")
}
styled.append("\n { rank=\"same\"; ${implNodes.sort().collect { "\"${it}\"" }.join("; ")} }\n")
styled.append(" { rank=\"same\"; ${apiNodes.sort().collect { "\"${it}\"" }.join("; ")} }\n\n")
appToImpl.each { e -> styled.append(" \"${e.from}\" -> \"${e.to}\"\n") }
styled.append("\n")
implToOwnApi.each { e -> styled.append(" \"${e.from}\" -> \"${e.to}\"\n") }
styled.append("\n")
crossDeps.each { e -> styled.append(" \"${e.from}\" -> \"${e.to}\" [color=\"#EF5350\" style=\"dashed\" constraint=\"false\"]\n") }
styled.append("\n")
apiToApi.each { e -> styled.append(" \"${e.from}\" -> \"${e.to}\" [color=\"#7E57C2\" penwidth=\"1.8\" constraint=\"false\"]\n") }
styled.append("\n")
apiToGlobal.each { e -> styled.append(" \"${e.from}\" -> \"${e.to}\" [style=\"dotted\" color=\"#BDBDBD\"]\n") }
styled.append("\n")
styled.append("""
subgraph cluster_legend {
label="Legend"
fontname="Helvetica Neue"
fontsize="13"
style="rounded"
color="#E0E0E0"
bgcolor="white"
margin="16"
labeljust="l"
edge [style="invis"]
l1 [label="app (진입점)" fillcolor="#1A237E" fontcolor="white" pencolor="#0D47A1"]
l2 [label="impl (구현)" fillcolor="#42A5F5" fontcolor="white" pencolor="#1E88E5"]
l3 [label="api (인터페이스)" fillcolor="#A5D6A7" fontcolor="#1B5E20" pencolor="#66BB6A"]
l4 [label="global (공통)" fillcolor="#FFB74D" fontcolor="#E65100" pencolor="#FFA726"]
l1 -> l2 -> l3 -> l4
}
}
""")
def styledDot = new File(outputDir, "dependency-graph-styled.dot")
styledDot.text = styled.toString()
logger.lifecycle("✅ DOT 파일 생성: ${styledDot}")
try {
exec {
commandLine("dot", "-Tsvg", "-o", "${outputDir}/dependency-graph-styled.svg", styledDot.absolutePath)
}
def svgFile = new File(outputDir, "dependency-graph-styled.svg")
def svgContent = svgFile.text
svgFile.text = svgContent.replaceFirst(/<svg width="[^"]*" height="[^"]*"/, '<svg width="100%" height="100vh"')
logger.lifecycle("✅ SVG 생성: ${svgFile}")
} catch (Exception e) {
logger.warn("⚠️ Graphviz(dot)가 설치되어 있지 않습니다. DOT 파일만 생성되었습니다.")
logger.warn(" 설치: brew install graphviz")
}
}
}