File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
13plugins {
24 id(" java-library" )
35 id(" com.github.johnrengelman.shadow" ) version " 8.1.1"
@@ -30,4 +32,27 @@ dependencies {
3032
3133tasks.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+ }
You can’t perform that action at this time.
0 commit comments