-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
238 lines (202 loc) · 8.3 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
238 lines (202 loc) · 8.3 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
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.report.ReportMergeTask
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
plugins {
base
alias(libs.plugins.kotlin.jvm)
// see: https://kotlinlang.org/docs/reference/compiler-plugins.html
alias(libs.plugins.kotlin.spring) apply false
alias(libs.plugins.kotlin.allopen) apply false
alias(libs.plugins.kotlin.noarg) apply false
alias(libs.plugins.kotlin.jpa) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.kotlinx.atomicfu)
alias(libs.plugins.detekt)
alias(libs.plugins.dependency.management)
alias(libs.plugins.spring.boot) apply false
alias(libs.plugins.test.logger)
alias(libs.plugins.graalvm.native) apply false
}
val rootLibs = libs
allprojects {
repositories {
mavenCentral()
google()
// Bluetape4k Snapshot 버전을 사용할 때만 사용하세요.
maven {
name = "central-portal-snapshots"
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
}
}
// Bluetape4k Snapshot 버전을 사용할 때만 사용하세요.
configurations.all {
resolutionStrategy.cacheChangingModulesFor(1, TimeUnit.DAYS)
}
}
subprojects {
apply {
plugin<JavaLibraryPlugin>()
// Kotlin 1.9.20 부터는 pluginId 를 지정해줘야 합니다.
plugin("org.jetbrains.kotlin.jvm")
// Atomicfu
plugin("org.jetbrains.kotlinx.atomicfu")
plugin("io.spring.dependency-management")
plugin("com.adarshr.test-logger")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
kotlin {
jvmToolchain(21)
compilerOptions {
languageVersion.set(KotlinVersion.KOTLIN_2_3)
apiVersion.set(KotlinVersion.KOTLIN_2_3)
freeCompilerArgs = listOf(
"-Xjsr305=strict",
"-jvm-default=enable",
// "-Xinline-classes", // Kotlin 2.3 부터는 불필요
"-Xstring-concat=indy", // since Kotlin 1.4.20 for JVM 9+
"-Xcontext-parameters", // since Kotlin 1.6
"-Xannotation-default-target=param-property"
)
val experimentalAnnotations = listOf(
"kotlin.RequiresOptIn",
"kotlin.ExperimentalStdlibApi",
"kotlin.contracts.ExperimentalContracts",
"kotlin.experimental.ExperimentalTypeInference",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.coroutines.InternalCoroutinesApi",
"kotlinx.coroutines.FlowPreview",
"kotlinx.coroutines.DelicateCoroutinesApi",
)
freeCompilerArgs.addAll(experimentalAnnotations.map { "-opt-in=$it" })
}
}
atomicfu {
transformJvm = true
jvmVariant = "VH" // FU, VH, BOTH
}
tasks {
compileJava {
options.isIncremental = true
}
compileKotlin {
compilerOptions {
incremental = true
}
}
// 멀티 모듈들을 테스트 시에만 동시에 실행되지 않게 하기 위해 Mutex 를 활용합니다.
abstract class TestMutexService: BuildService<BuildServiceParameters.None>
val testMutex = gradle.sharedServices.registerIfAbsent(
"test-mutex",
TestMutexService::class
) {
maxParallelUsages.set(1)
}
test {
// 멀티 모듈들을 테스트 시에만 동시에 실행되지 않게 하기 위해 Mutex 를 활용합니다.
usesService(testMutex)
useJUnitPlatform()
// 테스트 시 아래와 같은 예외 메시지를 제거하기 위해서
// OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
jvmArgs(
"-Xshare:off",
"-XX:+UseZGC",
"-Xms2G",
"-Xmx4G",
"-XX:+EnableDynamicAgentLoading",
"-Duser.language=en",
"-Duser.country=US"
)
if (project.name.contains("quarkus")) {
// [Quarkus Logging](https://quarkus.io/guides/logging)
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
}
// Gradle 프로퍼티를 JVM 시스템 프로퍼티로 전달하여 테스트 대상 DB를 제어합니다.
// 사용 예:
// ./gradlew test -PuseFastDB=true → H2 계열만 테스트
// ./gradlew test -PuseDB=H2,POSTGRESQL → 지정한 DB만 테스트
project.findProperty("useFastDB")?.toString()?.let {
systemProperty("exposed.test.useFastDB", it)
}
project.findProperty("useDB")?.toString()?.let {
systemProperty("exposed.test.useDB", it)
}
testLogging {
showExceptions = true
showCauses = true
showStackTraces = true
events("failed")
}
}
testlogger {
theme = com.adarshr.gradle.testlogger.theme.ThemeType.MOCHA_PARALLEL
showFullStackTraces = true
}
val reportMerge by registering(ReportMergeTask::class) {
val file = rootProject.layout.buildDirectory.asFile.get().resolve("reports/detekt/exposed.xml")
output.set(file)
}
withType<Detekt>().configureEach detekt@{
enabled = this@subprojects.name !== "exposed-tests"
finalizedBy(reportMerge)
reportMerge.configure {
input.from(this@detekt.xmlReportFile)
}
}
clean {
doLast {
delete("./.project")
delete("./out")
delete("./bin")
}
}
}
dependencyManagement {
// HINT: Gradle 빌드 시, detachedConfiguration 이 많이 발생하는데, setApplyMavenExclusions(false) 를 추가하면 속도가 개선됩니다.
// https://discuss.gradle.org/t/what-is-detachedconfiguration-i-have-a-lots-of-them-for-each-subproject-and-resolving-them-takes-95-of-build-time/31595/6
setApplyMavenExclusions(false)
imports {
mavenBom(rootLibs.spring.boot.dependencies.get().toString())
mavenBom(rootLibs.bluetape4k.bom.get().toString())
mavenBom(rootLibs.kotlinx.coroutines.bom.get().toString())
mavenBom(rootLibs.kotlin.bom.get().toString())
}
}
dependencies {
val api by configurations
val testApi by configurations
val implementation by configurations
val testImplementation by configurations
val compileOnly by configurations
val testCompileOnly by configurations
val testRuntimeOnly by configurations
implementation(rootLibs.kotlin.stdlib)
implementation(rootLibs.kotlin.reflect)
testImplementation(rootLibs.kotlin.test)
testImplementation(rootLibs.kotlin.test.junit5)
implementation(rootLibs.kotlinx.coroutines.core)
implementation(rootLibs.kotlinx.atomicfu)
// 개발 시에는 logback 이 검증하기에 더 좋고, Production에서 비동기 로깅은 log4j2 가 성능이 좋다고 합니다.
api(rootLibs.slf4j.api)
api(rootLibs.bluetape4k.logging)
implementation(rootLibs.logback)
testImplementation(rootLibs.jcl.over.slf4j)
testImplementation(rootLibs.jul.to.slf4j)
testImplementation(rootLibs.log4j.over.slf4j)
// JUnit 5
testImplementation(rootLibs.bluetape4k.junit5)
testImplementation(rootLibs.junit.jupiter)
testRuntimeOnly(rootLibs.junit.platform.engine)
testImplementation(rootLibs.junit.jupiter.migrationsupport)
testImplementation(rootLibs.kluent)
testImplementation(rootLibs.mockk)
testImplementation(rootLibs.awaitility.kotlin)
// Property based test
testImplementation(rootLibs.datafaker)
testImplementation(rootLibs.random.beans)
}
}