Fix steamwar.devserver.gradle

This commit is contained in:
2025-04-17 20:36:16 +02:00
parent 9001e83321
commit 335649fa87
2 changed files with 20 additions and 19 deletions
+1 -1
View File
@@ -73,5 +73,5 @@ tasks.register<DevServer>("DevVelocity") {
description = "Run a Dev Velocity"
dependsOn(":VelocityCore:shadowJar")
dependsOn(":VelocityCore:Persistent:jar")
template = "Velocity"
template = "DevVelocity"
}
+15 -14
View File
@@ -55,6 +55,13 @@ class DevServer extends DefaultTask {
if (worldName == null) worldName = properties.get("worldName")
host = properties.get("host")
if (worldName == null) {
throw new GradleException("Please supply the 'worldName' in a 'steamwar.properties' files either in this project dir or any parent project!")
}
if (host == null) {
throw new GradleException("Please supply the 'host' in a 'steamwar.properties' files either in this project dir or any parent project!")
}
}
doLast {
uploadDependencies()
@@ -75,7 +82,7 @@ class DevServer extends DefaultTask {
super()
doLast {
if (processInput != null) {
processInput.write("stop\n")
processInput.write(template.endsWith("Velocity") ? "end\n" : "stop\n")
processInput.flush()
}
}
@@ -94,28 +101,22 @@ class DevServer extends DefaultTask {
}
def archive = archiveTask.archiveFile.get().asFile
println("Uploading $archive to ~/plugins/${template}")
new ProcessBuilder("scp", archive.absolutePath, "$host:~/plugins/$template/${archive.name.replace("-all", "")}").start().waitFor()
println("Uploaded $archive to ~/plugins/${template}")
println("Uploading $archive to ~/$template/plugins")
new ProcessBuilder("scp", archive.absolutePath, "$host:~/$template/plugins/${archive.name.replace("-all", "")}").start().waitFor()
println("Uploaded $archive to ~/$template/plugins")
}
}
void startDevServer() {
def devPy = new StringBuilder()
if (template.endsWith("Velocity")) { // TODO Add this to the dev.py!
devPy.append("cd DevVelocity")
devPy.append("; java -jar Velocity.jar --port 25566")
} else {
devPy.append("dev.py")
def devPy = new StringBuilder().append("./dev.py")
if (port != null) devPy.append(" --port $port")
if (worldName != null) devPy.append(" -w $worldName")
devPy.append(" -p plugins/$template")
if (worldName != null) devPy.append(" -w $template/$worldName")
devPy.append(" -p $template/plugins")
if (jar != null) devPy.append(" --jar $jar")
println("Starting $template with command ${devPy.toString()}")
devPy.append(" $template")
}
def process = new ProcessBuilder("ssh", host, "-T", devPy.toString()).start();
def process = new ProcessBuilder("ssh", host, "-T", devPy.toString()).start()
def running = true;
def processOutput = new BufferedReader(new InputStreamReader(process.inputStream))
new Thread({