Skip to content

Commit b7cc4e9

Browse files
committed
build: run server testing plugin task
1 parent 1735bb3 commit b7cc4e9

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

build.gradle.kts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
13
plugins {
24
id("java-library")
35
id("com.github.johnrengelman.shadow") version "8.1.1"
@@ -30,4 +32,27 @@ dependencies {
3032

3133
tasks.shadowJar {
3234
archiveClassifier = "shaded"
33-
}
35+
}
36+
37+
tasks.register<Copy>("runServer") {
38+
outputs.upToDateWhen { false }
39+
dependsOn("shadowJar")
40+
val launcherRepo = "https://raw.githubusercontent.com/AllayMC/AllayLauncher/refs/heads/main/scripts"
41+
val cmdWin = "Invoke-Expression (Invoke-WebRequest -Uri \"${launcherRepo}/install_windows.ps1\").Content"
42+
val cmdLinux = "wget -qO- ${launcherRepo}/install_linux.sh | bash"
43+
val cwd = layout.buildDirectory.file("launcher").get().asFile.apply { mkdirs() }
44+
45+
val shadowJar = tasks.named("shadowJar", ShadowJar::class).get()
46+
from(shadowJar.archiveFile.get().asFile)
47+
into(cwd.resolve("plugins").apply { mkdirs() })
48+
49+
val isWindows = System.getProperty("os.name").startsWith("Windows")
50+
fun launch() = exec {
51+
workingDir = cwd
52+
if (isWindows) commandLine("powershell", "-Command", cmdWin)
53+
else commandLine("sh", "-c", cmdLinux)
54+
}
55+
56+
// https://github.com/gradle/gradle/issues/18716 // kill it manually by click X...
57+
doLast { launch() }
58+
}

0 commit comments

Comments
 (0)