Allow different interpreters for SubCreator build scripts

This commit is contained in:
ME1312 2019-01-14 11:02:17 -05:00
parent 9b01aebd87
commit df159f72fe
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
6 changed files with 10 additions and 42 deletions

View File

@ -122,7 +122,7 @@ public class InternalSubCreator extends SubCreator {
e.printStackTrace();
}
if (template.getBuildOptions().contains("Shell-Location")) {
if (template.getBuildOptions().contains("Executable")) {
File cache;
if (template.getBuildOptions().getBoolean("Use-Cache", true)) {
cache = new UniversalFile(host.plugin.dir, "SubServers:Cache:Templates:" + template.getName());
@ -132,22 +132,9 @@ public class InternalSubCreator extends SubCreator {
cache = null;
}
if (!System.getProperty("os.name").toLowerCase().startsWith("windows") && template.getBuildOptions().contains("Permission")) {
try {
Process process = Runtime.getRuntime().exec("chmod " + template.getBuildOptions().getRawString("Permission") + ' ' + template.getBuildOptions().getRawString("Shell-Location"), null, dir);
Thread.sleep(500);
if (process.exitValue() != 0) {
System.out.println(name + File.separator + "Creator > Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location"));
}
} catch (Exception e) {
System.out.println(name + File.separator + "Creator > Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location"));
e.printStackTrace();
}
}
try {
System.out.println(name + File.separator + "Creator > Launching " + template.getBuildOptions().getRawString("Shell-Location"));
ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(gitBash, "bash \"" + template.getBuildOptions().getRawString("Shell-Location") + '\"')).directory(dir);
System.out.println(name + File.separator + "Creator > Launching Build Script...");
ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(gitBash, template.getBuildOptions().getRawString("Executable"))).directory(dir);
pb.environment().putAll(var);
process = pb.start();
log.file = new File(dir, "SubCreator-" + template.getName() + "-" + version.toString() + ".log");

View File

@ -5,7 +5,6 @@ Template:
Build:
Server-Type: 'Forge'
Use-Cache: false
Shell-Location: 'build.sh'
Permission: '+x'
Executable: 'bash build.sh'
Settings:
Executable: 'java -Xmx2048M -jar Forge.jar'

View File

@ -4,7 +4,6 @@ Template:
Icon: 'lava_bucket'
Build:
Server-Type: 'Spigot'
Shell-Location: 'build.sh'
Permission: '+x'
Executable: 'bash build.sh'
Settings:
Executable: 'java -Xmx1024M -Dorg.bukkit.craftbukkit.libs.jline.terminal=unix -Djansi.passthrough=true -jar Spigot.jar -p $port$'

View File

@ -5,7 +5,6 @@ Template:
Build:
Server-Type: 'Sponge'
Use-Cache: false
Shell-Location: 'build.sh'
Permission: '+x'
Executable: 'bash build.sh'
Settings:
Executable: 'java -Xmx1024M -jar Sponge.jar'

View File

@ -4,7 +4,6 @@ Template:
Icon: 'bukkit:grass'
Build:
Server-Type: 'Vanilla'
Shell-Location: 'build.sh'
Permission: '+x'
Executable: 'bash build.sh'
Settings:
Executable: 'java -Xmx1024M -jar Vanilla.jar nogui'

View File

@ -280,25 +280,10 @@ public class SubCreator {
cache = null;
}
if (!System.getProperty("os.name").toLowerCase().startsWith("windows") && template.getBuildOptions().contains("Permission")) {
try {
Process process = Runtime.getRuntime().exec("chmod " + template.getBuildOptions().getRawString("Permission") + ' ' + template.getBuildOptions().getRawString("Shell-Location"), null, dir);
Thread.sleep(500);
if (process.exitValue() != 0) {
log.logger.info.println("Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location"));
host.subdata.sendPacket(new PacketOutExLogMessage(address, "Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location")));
}
} catch (Exception e) {
log.logger.info.println("Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location"));
host.subdata.sendPacket(new PacketOutExLogMessage(address, "Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location")));
log.logger.error.println(e);
}
}
try {
log.logger.info.println("Launching " + template.getBuildOptions().getRawString("Shell-Location"));
host.subdata.sendPacket(new PacketOutExLogMessage(address, "Launching " + template.getBuildOptions().getRawString("Shell-Location")));
ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(host.host.getRawString("Git-Bash"), "bash \"" + template.getBuildOptions().getRawString("Shell-Location") + '\"')).directory(dir);
log.logger.info.println("Launching Build Script...");
host.subdata.sendPacket(new PacketOutExLogMessage(address, "Launching Build Script..."));
ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(host.host.getRawString("Git-Bash"), template.getBuildOptions().getRawString("Executable"))).directory(dir);
pb.environment().putAll(var);
process = pb.start();
log.file = new File(dir, "SubCreator-" + template.getName() + "-" + version.toString().replace(" ", "@") + ".log");