-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
85 lines (71 loc) · 2.45 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
import com.jtitor.plugin.gradle.rust.tasks.RustBuild
import org.jetbrains.kotlin.gradle.internal.ensureParentDirsCreated
plugins {
kotlin("jvm") version "1.9.0"
kotlin("plugin.serialization") version "1.9.0"
id("com.jtitor.rust") version "0.1.4"
application
}
group = "org.elliotnash"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven("https://repo.elliotnash.org/snapshots")
mavenLocal()
}
dependencies {
implementation("org.elliotnash.blueify:Blueify:1.3.0-SNAPSHOT")
// KotlinX libraries
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1")
implementation("com.akuleshov7:ktoml-core:0.5.0")
implementation("com.akuleshov7:ktoml-file:0.5.0")
// Logging
implementation("org.slf4j:slf4j-api:2.0.7")
implementation("org.apache.logging.log4j:log4j-api:2.20.0")
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0")
implementation("io.github.oshai:kotlin-logging-jvm:5.0.2")
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(17)
}
application {
mainClass.set("org.elliotnash.tim.TiMKt")
}
tasks {
val fatJar = register<Jar>("fatJar") {
archiveFileName.set("TiM.jar")
dependsOn.addAll(listOf("compileJava", "compileKotlin", "processResources")) // We need this for Gradle optimization to work
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest { attributes(mapOf("Main-Class" to application.mainClass)) } // Provided we set it up in the application plugin configuration
val sourcesMain = sourceSets.main.get()
val contents = configurations.runtimeClasspath.get()
.map { if (it.isDirectory) it else zipTree(it) } +
sourcesMain.output
from(contents)
}
val buildRust = register<Exec>("buildRust") {
doFirst {
exec {
commandLine("chmod", "+x", "./scripts/build-rust.sh")
}
}
commandLine("./scripts/build-rust.sh")
}
build {
dependsOn(fatJar) // Trigger fat jar creation during build
}
// Build rust when building kotlin
compileKotlin {
dependsOn(buildRust)
}
compileTestKotlin {
dependsOn(buildRust)
}
}