Search in sources :

Example 1 with Argument

use of org.platformlayer.ops.Command.Argument in project platformlayer by platformlayer.

the class JavaCommandBuilder method get.

public Command get() {
    Command command = Command.build("java");
    command.addLiteral("-server");
    for (Map.Entry<String, String> define : defines.entrySet()) {
        command.addLiteral("-D" + define.getKey() + "=" + define.getValue());
    }
    StringBuilder cp = new StringBuilder();
    for (ClasspathEntry entry : classpath) {
        if (cp.length() != 0) {
            cp.append(":");
        }
        String s = entry.path.getAbsolutePath();
        if (entry.wildcard) {
            // TODO: Adding * is gross
            s += "/*";
        }
        cp.append(s);
    }
    // TODO: This is not nice either
    if (cp.length() == 0) {
        cp.append(".");
    } else {
        cp.append(":.");
    }
    command.addLiteral("-cp").addQuoted(cp.toString());
    if (jar != null) {
        command.addLiteral("-jar").addFile(jar);
    } else {
        command.addQuoted(mainClass);
    }
    for (Argument argument : arguments) {
        command.addArgument(argument);
    }
    return command;
}
Also used : Argument(org.platformlayer.ops.Command.Argument) Command(org.platformlayer.ops.Command) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 Command (org.platformlayer.ops.Command)1 Argument (org.platformlayer.ops.Command.Argument)1