diff --git a/build.gradle b/build.gradle index 23f171a..1e22a8f 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ subprojects { } subprojects { - if (!it.name.startsWith('bridge')) { + if (!it.name.startsWith('bridge') && !it.name.startsWith('zond')) { ext { slf4jVersion = '1.7.21' } diff --git a/settings.gradle b/settings.gradle index df0ccb4..02de200 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,3 +4,4 @@ include 'webinterface' include 'mcserver-manager' include 'bridge-protocol' include 'bridge' +include 'zond' diff --git a/zond/build.gradle b/zond/build.gradle new file mode 100644 index 0000000..36d2c8c --- /dev/null +++ b/zond/build.gradle @@ -0,0 +1,26 @@ +group = 'asys' +version = '0.1-SNAPSHOT' + +apply plugin: 'application' + +mainClassName = "asys.zond.Main" + +configurations { + included + compile.extendsFrom included +} + +jar { + manifest { + attributes 'Implementation-Title': 'ASys Zond', + 'Implementation-Version': version, + 'Main-Class': mainClassName + } + baseName = project.group + '.' + project.name + from { configurations.included.collect { it.isDirectory() ? it : zipTree(it) } } +} + +dependencies { + included group: 'org.fusesource.jansi', name: 'jansi', version: '1.11' + included group: 'org.apache.commons', name: 'commons-exec', version: '1.3' +} diff --git a/zond/src/main/java/asys/zond/Main.java b/zond/src/main/java/asys/zond/Main.java new file mode 100644 index 0000000..9623b35 --- /dev/null +++ b/zond/src/main/java/asys/zond/Main.java @@ -0,0 +1,54 @@ +/* + * DmitriyMX + * 2017-06-07 + * Idea by Daniil on 2017-06-07 + */ +package asys.zond; + +import org.apache.commons.exec.CommandLine; +import org.apache.commons.exec.DefaultExecutor; +import org.apache.commons.exec.ExecuteException; +import org.apache.commons.exec.PumpStreamHandler; +import org.fusesource.jansi.Ansi; +import org.fusesource.jansi.Ansi.Color; +import org.fusesource.jansi.AnsiConsole; + +import java.io.IOException; +import java.util.Arrays; +import java.util.stream.Collectors; + +import static org.fusesource.jansi.Ansi.ansi; + +public class Main { + public static void main(String[] args) throws IOException { + if (Boolean.getBoolean("ansi.install")) { + AnsiConsole.systemInstall(); + } + + Ansi ansi = ansi().reset(); + ansi.bold().fg(Color.WHITE).a("ASys").boldOff().a(":// "); + ansi.fg(Color.BLACK).bg(Color.RED).a("Zond").reset().newline(); + System.out.println(ansi.toString()); + + if (args.length == 0) { + System.out.println("no args"); + System.exit(0); + return; + } + + String cmdLine = Arrays.stream(args).collect(Collectors.joining(" ")); + CommandLine commandLine = CommandLine.parse(cmdLine); + DefaultExecutor executor = new DefaultExecutor(); + executor.setExitValue(1); + executor.setStreamHandler(new PumpStreamHandler(System.out, System.err, System.in)); + + int resultCode = 0; + try { + resultCode = executor.execute(commandLine); + } catch (ExecuteException ignore) { + } + System.out.print(ansi().reset().newline() + .fg(Color.GREEN).a("Process Finished. Code: ") + .bold().fg(Color.WHITE).a(resultCode).reset().newline()); + } +}