-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
86 lines (77 loc) · 2.41 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
val javaVersion = JavaVersion.VERSION_21
plugins {
kotlin("jvm") version "2.0.21"
id("com.diffplug.spotless") version "6.25.0"
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
maven("https://packages.confluent.io/maven/")
maven {
url = uri("https://github-package-registry-mirror.gc.nav.no/cached/maven-release")
}
}
}
subprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "com.diffplug.spotless")
spotless {
kotlin {
ktlint()
.editorConfigOverride(
mapOf(
"ktlint_standard_max-line-length" to "off",
),
)
}
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = javaVersion.toString()
}
compileTestKotlin {
kotlinOptions.jvmTarget = javaVersion.toString()
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
test {
// JUnit 5 support
useJUnitPlatform()
// https://phauer.com/2018/best-practices-unit-testing-kotlin/
systemProperty("junit.jupiter.testinstance.lifecycle.default", "per_class")
if (javaVersion.isCompatibleWith(JavaVersion.VERSION_21)) {
// https://github.com/mockito/mockito/issues/3037#issuecomment-1588199599
jvmArgs("-XX:+EnableDynamicAgentLoading")
}
}
}
configurations.all {
// exclude JUnit 4
exclude(group = "junit", module = "junit")
}
}
tasks.register<Copy>("gitHooks") {
from(file(".scripts/pre-commit"))
into(file(".git/hooks"))
}
tasks.named("build") {
dependsOn("gitHooks")
}
tasks.register("checkFlywayMigrationNames") {
doLast {
val migrationDir = project.file("app/src/main/resources/db/migration")
val invalidFiles = migrationDir.walk()
.filter { it.isFile && it.extension == "sql" }
.filterNot { it.name.matches(Regex("V[0-9]+__[\\w]+\\.sql")) }
.map { it.name }
.toList()
if (invalidFiles.isNotEmpty()) {
throw GradleException("Invalid migration filenames:\n${invalidFiles.joinToString("\n")}")
} else {
println("All migration filenames are valid.")
}
}
}
tasks.named("check") {
dependsOn("checkFlywayMigrationNames")
}