-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
91 lines (79 loc) · 2.6 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.ByteArrayOutputStream
plugins {
kotlin("jvm") version "2.1.10"
}
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
dependencies {
fun klite(module: String) = "com.github.codeborne.klite:klite-$module:1.6.13"
implementation(klite("server"))
implementation(klite("json"))
implementation(klite("i18n"))
implementation(klite("jdbc"))
implementation(klite("slf4j"))
implementation("org.postgresql:postgresql:42.7.5")
testImplementation(klite("jdbc-test"))
testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.4")
testImplementation("ch.tutteli.atrium:atrium-fluent:1.3.0-alpha-1")
testImplementation("io.mockk:mockk:1.13.16")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0")
}
sourceSets {
main {
kotlin.setSrcDirs(listOf("src"))
resources.setSrcDirs(listOf("src", "db")).exclude("**/*.kt")
}
test {
kotlin.setSrcDirs(listOf("test"))
resources.setSrcDirs(listOf("test")).exclude("**/*.kt")
}
}
tasks.test {
workingDir(rootDir)
useJUnitPlatform()
// enable JUnitAssertionImprover from klite.jdbc-test
jvmArgs("-DENV=test", "-Djunit.jupiter.extensions.autodetection.enabled=true", "--add-opens=java.base/java.lang=ALL-UNNAMED", "-XX:-OmitStackTraceInFastThrow")
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "21"
if (System.getProperty("user.name") != "root") finalizedBy("types.ts")
}
tasks.register<Copy>("deps") {
into("$buildDir/libs/deps")
from(configurations.runtimeClasspath)
}
val mainClassName = "LauncherKt"
tasks.jar {
dependsOn("deps")
doFirst {
manifest {
attributes(
"Main-Class" to mainClassName,
"Class-Path" to File("$buildDir/libs/deps").listFiles()?.joinToString(" ") { "deps/${it.name}"}
)
}
}
}
tasks.register<JavaExec>("run") {
workingDir(rootDir)
jvmArgs("--add-exports=java.base/sun.net.www=ALL-UNNAMED")
mainClass.set(mainClassName)
classpath = sourceSets.main.get().runtimeClasspath
}
tasks.register<JavaExec>("types.ts") {
dependsOn("classes")
mainClass.set("klite.json.TSGenerator")
classpath = sourceSets.main.get().runtimeClasspath
args("${project.buildDir}/classes/kotlin/main")
standardOutput = ByteArrayOutputStream()
doLast {
project.file("ui/src/api/types.ts").writeText("""
export type Id<T extends Entity<T>> = string & {_of?: T}
export type Entity<T extends Entity<T>> = {id: Id<T>}
""".trimIndent() + "\n\n" + standardOutput.toString().replace("TSID", "Id"))
}
}