-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
93 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
92
93
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("com.github.johnrengelman.shadow") version "7.1.1"
kotlin("jvm") version "1.6.10"
application
}
application {
mainClass.set("strumbot.Main")
}
group = "dev.minn"
version = "1.3.6"
repositories {
mavenLocal() // caching optimization
mavenCentral() // everything else
maven("https://m2.dv8tion.net/releases") // jda
maven("https://jitpack.io") // jda-reactor and slash commands
}
dependencies {
implementation("net.dv8tion:JDA:4.+") {
exclude(module="opus-java")
}
implementation("com.github.minndevelopment:jda-ktx:34b55c0")
implementation("ch.qos.logback:logback-classic:1.2.8")
implementation("com.squareup.okhttp3:okhttp:4.9.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation(kotlin("stdlib-jdk8"))
}
val clean by tasks
val build by tasks
val compileKotlin: KotlinCompile by tasks
val shadowJar: ShadowJar by tasks
compileKotlin.kotlinOptions.apply {
jvmTarget = "11"
freeCompilerArgs = listOf(
"-Xjvm-default=all", // use default methods in interfaces
"-Xlambdas=indy" // use invokedynamic lambdas instead of synthetic classes
)
}
build.dependsOn(shadowJar)
fun setupScript(path: String) {
val file = File(path)
file.writeText(file.readText()
.replace("%NAME%", "strumbot.jar")
.replace("%VERSION%", version.toString()))
file.setExecutable(true)
file.setReadable(true)
}
tasks.create<Copy>("release") {
group = "build"
shadowJar.mustRunAfter(clean)
dependsOn(shadowJar)
dependsOn(clean)
from(shadowJar.archiveFile.get())
from("src/scripts")
from("example-config.json")
val output = "$buildDir/release/strumbot"
into("$output/")
doFirst { File(output).delete() }
doLast {
setupScript("$output/run.bat")
setupScript("$output/run.sh")
setupScript("$output/docker-setup.sh")
setupScript("$output/docker-setup.bat")
val archive = File("$output/${shadowJar.archiveFileName.get()}")
archive.renameTo(File("$output/strumbot.jar"))
val config = File("$output/example-config.json")
config.renameTo(File("$output/config.json"))
File("containers/docker-compose.yml").let { file ->
file.writeText(
file.readText()
.replace(
Regex("(minnced/strumbot):.+?(-min)?(\\s+)"),
"\$1:$version\$2\$3"
)
)
}
}
}