Add steamwar.properties 'worldName' and 'host'

Remove some options
This commit is contained in:
2025-04-17 15:24:12 +02:00
parent 32703c6659
commit 9001e83321
2 changed files with 25 additions and 19 deletions
-5
View File
@@ -1,5 +1,3 @@
import DevServer
/* /*
* This file is a part of the SteamWar software. * This file is a part of the SteamWar software.
* *
@@ -22,7 +20,6 @@ import DevServer
plugins { plugins {
`java-library` `java-library`
alias(libs.plugins.shadow) alias(libs.plugins.shadow)
steamwar.devserver
} }
tasks.build { tasks.build {
@@ -43,7 +40,6 @@ tasks.register<DevServer>("DevBau20") {
description = "Run a 1.20 Dev Bau" description = "Run a 1.20 Dev Bau"
dependsOn(":SpigotCore:shadowJar") dependsOn(":SpigotCore:shadowJar")
dependsOn(":BauSystem:shadowJar") dependsOn(":BauSystem:shadowJar")
worldName = "245"
template = "Bau20" template = "Bau20"
} }
@@ -52,6 +48,5 @@ tasks.register<DevServer>("DevBau21") {
description = "Run a 1.21 Dev Bau" description = "Run a 1.21 Dev Bau"
dependsOn(":SpigotCore:shadowJar") dependsOn(":SpigotCore:shadowJar")
dependsOn(":BauSystem:shadowJar") dependsOn(":BauSystem:shadowJar")
worldName = "245"
template = "Bau21" template = "Bau21"
} }
+25 -14
View File
@@ -32,20 +32,30 @@ class DevServer extends DefaultTask {
@Optional @Optional
Integer port = null Integer port = null
@Input
@Optional
Boolean profile = false
@Input
@Optional
Boolean forceUpgrade = false
@Input @Input
@Optional @Optional
String jar = null String jar = null
DevServer() { DevServer() {
super() super()
doFirst {
List<Project> projects = []
projects.add(project)
while (projects.first.parent != null) {
projects.add(0, projects.first.parent)
}
def properties = new Properties()
projects.forEach {
def file = new File(it.projectDir, "steamwar.properties")
if (file.exists()) {
properties.load(new FileInputStream(file))
}
}
if (worldName == null) worldName = properties.get("worldName")
host = properties.get("host")
}
doLast { doLast {
uploadDependencies() uploadDependencies()
startDevServer() startDevServer()
@@ -54,7 +64,10 @@ class DevServer extends DefaultTask {
} }
@Internal @Internal
BufferedWriter processInput; BufferedWriter processInput
@Internal
String host
class Finalizer extends DefaultTask { class Finalizer extends DefaultTask {
@@ -82,14 +95,14 @@ class DevServer extends DefaultTask {
def archive = archiveTask.archiveFile.get().asFile def archive = archiveTask.archiveFile.get().asFile
println("Uploading $archive to ~/plugins/${template}") println("Uploading $archive to ~/plugins/${template}")
new ProcessBuilder("scp", archive.absolutePath, "sw:~/plugins/$template/${archive.name.replace("-all", "")}").start().waitFor() new ProcessBuilder("scp", archive.absolutePath, "$host:~/plugins/$template/${archive.name.replace("-all", "")}").start().waitFor()
println("Uploaded $archive to ~/plugins/${template}") println("Uploaded $archive to ~/plugins/${template}")
} }
} }
void startDevServer() { void startDevServer() {
def devPy = new StringBuilder() def devPy = new StringBuilder()
if (template.endsWith("Velocity")) { if (template.endsWith("Velocity")) { // TODO Add this to the dev.py!
devPy.append("cd DevVelocity") devPy.append("cd DevVelocity")
devPy.append("; java -jar Velocity.jar --port 25566") devPy.append("; java -jar Velocity.jar --port 25566")
} else { } else {
@@ -97,14 +110,12 @@ class DevServer extends DefaultTask {
if (port != null) devPy.append(" --port $port") if (port != null) devPy.append(" --port $port")
if (worldName != null) devPy.append(" -w $worldName") if (worldName != null) devPy.append(" -w $worldName")
devPy.append(" -p plugins/$template") devPy.append(" -p plugins/$template")
if (profile) devPy.append(" --profile")
if (forceUpgrade) devPy.append(" --forceUpgrade")
if (jar != null) devPy.append(" --jar $jar") if (jar != null) devPy.append(" --jar $jar")
println("Starting $template with command ${devPy.toString()}") println("Starting $template with command ${devPy.toString()}")
devPy.append(" $template") devPy.append(" $template")
} }
def process = new ProcessBuilder("ssh", "sw", "-T", devPy.toString()).start(); def process = new ProcessBuilder("ssh", host, "-T", devPy.toString()).start();
def running = true; def running = true;
def processOutput = new BufferedReader(new InputStreamReader(process.inputStream)) def processOutput = new BufferedReader(new InputStreamReader(process.inputStream))
new Thread({ new Thread({