Add a check if the template exists in the user.home directory

This commit is contained in:
2025-04-18 07:53:46 +02:00
parent 5669725f9b
commit 4edfd32ff5
+10
View File
@@ -66,6 +66,7 @@ class DevServer extends DefaultTask {
} }
} }
doLast { doLast {
checkHasTemplate()
uploadDependencies() uploadDependencies()
startDevServer() startDevServer()
} }
@@ -91,6 +92,14 @@ class DevServer extends DefaultTask {
} }
} }
void checkHasTemplate() {
def process = new ProcessBuilder("ssh", host, "-T", "ls $template").start()
process.waitFor()
if (new BufferedReader(new InputStreamReader(process.inputStream)).lines().count() < 4) {
throw new GradleException("Used template is not in your user.home directory of the given host $host")
}
}
void uploadDependencies() { void uploadDependencies() {
this.dependsOn.forEach { this.dependsOn.forEach {
Project resolved Project resolved
@@ -104,6 +113,7 @@ class DevServer extends DefaultTask {
def archive = archiveTask.archiveFile.get().asFile def archive = archiveTask.archiveFile.get().asFile
println("Uploading $archive to ~/$template/plugins") println("Uploading $archive to ~/$template/plugins")
new ProcessBuilder("ssh", host, "-T", "rm $template/plugins/${archive.name.replace("-all", "")}").start().waitFor()
new ProcessBuilder("scp", archive.absolutePath, "$host:~/$template/plugins/${archive.name.replace("-all", "")}").start().waitFor() new ProcessBuilder("scp", archive.absolutePath, "$host:~/$template/plugins/${archive.name.replace("-all", "")}").start().waitFor()
println("Uploaded $archive to ~/$template/plugins") println("Uploaded $archive to ~/$template/plugins")
} }