Skip to content

Commit e9f2dd6

Browse files
authored
Merge pull request #1 from Cdm2883/master
build: run server testing plugin task
2 parents 1735bb3 + 6e5a122 commit e9f2dd6

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ Copy the `.jar` file to the `plugins` directory of your allay server.
3939
Start the allay server and check the logs to ensure your plugin loads and operates
4040
as expected.
4141

42+
5. **Test Your Plugin in Gradle**
43+
44+
```bash
45+
gradlew runServer
46+
```
47+
48+
This command will start an allay server with your plugin loaded.
49+
Then close allay server by clicking `X` in the dashboard window.
50+
4251
## Documentation
4352

4453
For a deeper dive into the Allay API and its functionalities, please refer to our [documentation](https://docs.allaymc.org) (WIP).

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)