-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle.kts
320 lines (267 loc) · 11.2 KB
/
build.gradle.kts
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
plugins {
base
`maven-publish`
jacoco
kotlin("jvm") version Versions.kotlin
// see: https://kotlinlang.org/docs/reference/compiler-plugins.html
kotlin("plugin.spring") version Versions.kotlin apply false
kotlin("plugin.allopen") version Versions.kotlin apply false
kotlin("plugin.noarg") version Versions.kotlin apply false
kotlin("plugin.jpa") version Versions.kotlin apply false
kotlin("plugin.serialization") version Versions.kotlin apply false
// kotlin("plugin.atomicfu") version Versions.kotlin apply false
kotlin("kapt") version Versions.kotlin apply false
//id(BuildPlugins.detekt) version BuildPlugins.Versions.detekt apply false
id(BuildPlugins.dokka) version BuildPlugins.Versions.dokka apply false
id(BuildPlugins.dependency_management) version BuildPlugins.Versions.dependency_management
id(BuildPlugins.spring_boot) version BuildPlugins.Versions.spring_boot apply false
}
allprojects {
repositories {
mavenCentral()
google()
}
}
subprojects {
apply {
plugin<JavaLibraryPlugin>()
plugin<KotlinPlatformJvmPlugin>()
plugin("jacoco")
plugin("maven-publish")
// plugin("io.gitlab.arturbosch.detekt")
plugin("org.jetbrains.dokka")
plugin("io.spring.dependency-management")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
val javaVersion = JavaVersion.VERSION_17.toString()
tasks {
compileJava {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
compileKotlin {
kotlinOptions {
jvmTarget = javaVersion
languageVersion = "1.8"
apiVersion = "1.8"
freeCompilerArgs = listOf(
"-Xjsr305=strict",
"-Xjvm-default=all",
"-Xinline-classes",
"-Xallow-result-return-type",
"-Xstring-concat=indy", // since Kotlin 1.4.20 for JVM 9+
"-progressive", // since Kotlin 1.6
"-Xenable-builder-inference", // since Kotlin 1.6
"-Xbackend-threads=0", // since 1.6.20 (0 means one thread per CPU core)
// "-Xuse-k2" // since Kotlin 1.7 // kapt not support
)
val experimentalAnnotations = listOf(
"kotlin.RequiresOptIn",
"kotlin.contracts.ExperimentalContracts",
"kotlin.experimental.ExperimentalTypeInference",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.coroutines.InternalCoroutinesApi",
"kotlinx.coroutines.FlowPreview",
)
freeCompilerArgs = freeCompilerArgs.plus(experimentalAnnotations.map { "-opt-in=$it" })
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = javaVersion
languageVersion = "1.8"
apiVersion = "1.8"
freeCompilerArgs = listOf(
"-Xjsr305=strict",
"-Xjvm-default=all",
"-Xinline-classes",
"-Xallow-result-return-type",
"-Xstring-concat=indy", // since Kotlin 1.4.20 for JVM 9+
"-progressive", // since Kotlin 1.6
"-Xenable-builder-inference", // since Kotlin 1.6
"-Xbackend-threads=0", // since 1.6.20 (0 means one thread per CPU core)
// "-Xuse-k2" // since Kotlin 1.7 // kapt not support
)
val experimentalAnnotations = listOf(
"kotlin.RequiresOptIn",
"kotlin.Experimental",
"kotlin.ExperimentalStdlibApi",
"kotlin.time.ExperimentalTime",
"kotlin.contracts.ExperimentalContracts",
// "kotlin.experimental.ExperimentalTypeInference",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.coroutines.InternalCoroutinesApi",
"kotlinx.coroutines.FlowPreview",
)
freeCompilerArgs = freeCompilerArgs.plus(experimentalAnnotations.map { "-opt-in=$it" })
}
}
}
val sourceSets = project.the<SourceSetContainer>()
val sourcesJar by tasks.creating(Jar::class) {
from(sourceSets["main"].allSource)
archiveClassifier.set("sources")
}
// Configure existing Dokka task to output HTML to typical Javadoc directory
val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$buildDir/javadoc"
}
// Create dokka Jar task from dokka task output
val dokkaJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Kotlin docs with Dokka"
archiveClassifier.set("javadoc")
// dependsOn(tasks.dokka) not needed; dependency automatically inferred by from(tasks.dokka)
from(dokka)
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events("failed")
}
}
// detekt {
// description = "Runs a failfast detekt build."
//
// input = files("src/main/kotlin")
// config = files("${project.rootProject.rootDir}/detekt.yml")
// filters = ".*/build/.*"
//
// reports {
// xml.enabled = false
// html.enabled = true
// }
// }
// jacoco
configure<JacocoPluginExtension> {
}
tasks.withType<JacocoReport> {
reports {
html.required.set(true)
xml.required.set(true)
csv.required.set(false)
}
}
tasks["clean"].doLast {
delete("./.project")
delete("./out")
delete("./bin")
}
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:${Versions.spring_boot}")
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${Versions.spring_cloud}")
mavenBom(Libraries.kotlin_bom)
}
dependencies {
dependency(Libraries.kotlin_stdlib)
dependency(Libraries.kotlin_stdlib_jdk7)
dependency(Libraries.kotlin_stdlib_jdk8)
dependency(Libraries.kotlin_reflect)
dependency(Libraries.kotlin_test)
dependency(Libraries.kotlin_test_junit5)
dependency(Libraries.kotlinx_coroutines_core)
dependency(Libraries.kotlinx_coroutines_jdk7)
dependency(Libraries.kotlinx_coroutines_jdk8)
dependency(Libraries.kotlinx_coroutines_reactor)
dependency(Libraries.kotlinx_coroutines_rx2)
// Apache Commons
dependency(Libraries.commons_collections4)
dependency(Libraries.commons_lang3)
dependency(Libraries.commons_compress)
dependency(Libraries.commons_codec)
dependency(Libraries.commons_csv)
dependency(Libraries.commons_math3)
dependency(Libraries.commons_pool2)
dependency(Libraries.commons_text)
dependency(Libraries.commons_exec)
dependency(Libraries.commons_io)
dependency(Libraries.kotlin_logging)
dependency(Libraries.slf4j_api)
dependency(Libraries.logback)
dependency(Libraries.findbugs)
dependency(Libraries.guava)
dependency(Libraries.joda_time)
dependency(Libraries.fst)
dependency(Libraries.kryo)
dependency(Libraries.kryo_serializers)
// Jackson
dependency(Libraries.jackson_annotations)
dependency(Libraries.jackson_core)
dependency(Libraries.jackson_databind)
dependency(Libraries.jackson_datatype_jsr310)
dependency(Libraries.jackson_datatype_jdk8)
dependency(Libraries.jackson_datatype_joda)
dependency(Libraries.jackson_datatype_guava)
dependency(Libraries.jackson_module_paranamer)
dependency(Libraries.jackson_module_parameter_names)
dependency(Libraries.jackson_module_kotlin)
dependency(Libraries.jackson_module_afterburner)
// Reactor
dependency(Libraries.reactor_core)
dependency(Libraries.reactor_kotlin_extensions)
dependency(Libraries.reactor_netty)
dependency(Libraries.reactor_test)
dependency(Libraries.hikaricp)
dependency(Libraries.mysql_connector_java)
dependency(Libraries.mariadb_java_client)
dependency(Libraries.h2)
// Mongo Driver
dependency(Libraries.mongo_bson)
dependency(Libraries.mongo_driver_core)
dependency(Libraries.mongo_driver_sync)
dependency(Libraries.mongo_driver_reactivestreams)
dependency(Libraries.byte_buddy)
dependency(Libraries.byte_buddy_agent)
dependency(Libraries.objenesis)
dependency(Libraries.ow2_asm)
dependency(Libraries.junit_jupiter)
dependency(Libraries.junit_jupiter_api)
dependency(Libraries.junit_jupiter_engine)
dependency(Libraries.junit_jupiter_params)
dependency(Libraries.junit_platform_commons)
dependency(Libraries.junit_platform_engine)
dependency(Libraries.kluent)
dependency(Libraries.assertj_core)
dependency(Libraries.mockk)
dependency(Libraries.mockito_core)
dependency(Libraries.mockito_junit_jupiter)
dependency(Libraries.mockito_kotlin)
dependency(Libraries.testcontainers)
}
}
dependencies {
val api by configurations
val implementation by configurations
val testImplementation by configurations
val testRuntimeOnly by configurations
implementation(Libraries.kotlin_stdlib)
implementation(Libraries.kotlin_stdlib_jdk8)
implementation(Libraries.kotlin_reflect)
testImplementation(Libraries.kotlin_test)
testImplementation(Libraries.kotlin_test_junit5)
implementation(Libraries.kotlinx_coroutines_jdk8)
// implementation(Libraries.atomicfu)
api(Libraries.commons_lang3)
api(Libraries.kotlin_logging)
testImplementation(Libraries.logback)
testImplementation(Libraries.junit_jupiter)
testRuntimeOnly(Libraries.junit_platform_engine)
testImplementation(Libraries.kluent)
testImplementation(Libraries.assertj_core)
testImplementation(Libraries.testcontainers)
}
}
//dependencies {
// // Make the root project archives configuration depend on every subproject
// subprojects.forEach {
// archives(it)
// }
//}