-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
72 lines (60 loc) · 2.62 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
kotlin("jvm") version "2.1.0"
id("com.gradleup.shadow") version "8.3.0"
}
group = "vip.cdms.allayplugin"
description = "Hello Allay from Kotlin!"
version = "0.1.0-alpha"
repositories {
mavenCentral()
maven("https://jitpack.io/")
maven("https://repo.opencollab.dev/maven-releases/")
maven("https://repo.opencollab.dev/maven-snapshots/")
maven("https://storehouse.okaeri.eu/repository/maven-public/")
}
dependencies {
@Suppress("VulnerableLibrariesLocal", "RedundantSuppression")
compileOnly(group = "org.allaymc.allay", name = "api", version = "master-SNAPSHOT")
implementation(group = "com.github.MineBuilders", name = "allaymc-kotlinx", version = "master-SNAPSHOT")
// TODO: uncomment to use kotlin shared lib
// compileOnly(kotlin("stdlib"))
// compileOnly(kotlin("stdlib-jdk7"))
// compileOnly(kotlin("stdlib-jdk8"))
// compileOnly(kotlin("reflect"))
}
kotlin {
jvmToolchain(21)
}
tasks.register<Copy>("runServer") {
outputs.upToDateWhen { false }
dependsOn("shadowJar")
val launcherRepo = "https://raw.githubusercontent.com/AllayMC/AllayLauncher/refs/heads/main/scripts"
val cmdWin = "Invoke-Expression (Invoke-WebRequest -Uri \"${launcherRepo}/install_windows.ps1\").Content"
val cmdLinux = "wget -qO- ${launcherRepo}/install_linux.sh | bash"
val cwd = layout.buildDirectory.file("run").get().asFile
val shadowJar = tasks.named("shadowJar", ShadowJar::class).get()
from(shadowJar.archiveFile.get().asFile)
into(cwd.resolve("plugins").apply { mkdirs() })
val isDownloaded = cwd.listFiles()!!.any { it.isFile && it.nameWithoutExtension == "allay" }
val isWindows = System.getProperty("os.name").startsWith("Windows")
fun launch() = exec {
workingDir = cwd
val cmd = if (isDownloaded) "./allay" else if (isWindows) cmdWin else cmdLinux
if (isWindows) commandLine("powershell", "-Command", cmd)
else commandLine("sh", "-c", cmd)
}
// https://github.com/gradle/gradle/issues/18716 // kill it manually by click X...
doLast { launch() }
}
tasks.named("processResources") {
doLast {
val origin = file("src/main/resources/plugin.json")
val processed = file("${layout.buildDirectory.get()}/resources/main/plugin.json")
val content = origin.readText()
.replace("\"entrance\": \".", "\"entrance\": \"" + project.group.toString() + ".")
.replace("\${description}", project.description.toString())
.replace("\${version}", version.toString())
processed.writeText(content)
}
}