Examples of ArgumentListBuilder


Examples of hudson.util.ArgumentListBuilder

     * arguments.
     */
    private ArgumentListBuilder buildCmdLine(AbstractBuild build,
                                             Launcher launcher, BuildListener listener)
        throws IllegalArgumentException, InterruptedException, IOException {
        ArgumentListBuilder args = new ArgumentListBuilder();

//    DescriptorImpl descriptor = (DescriptorImpl) getDescriptor();

        EnvVars env = build.getEnvironment(listener);
        env.overrideAll(build.getBuildVariables());

        SbtInstallation sbt = getSbt();
        if (sbt == null) {
            throw new IllegalArgumentException("sbt-launch.jar not found");
        } else {
            sbt = sbt.forNode(Computer.currentComputer().getNode(), listener);
            sbt = sbt.forEnvironment(env);

            String launcherPath = sbt.getSbtLaunchJar(launcher);

            if (launcherPath == null) {
                throw new IllegalArgumentException("sbt-launch.jar not found");
            }

            if (!launcher.isUnix()) {
                args.add("cmd.exe", "/C");
                // add an extra set of quotes after cmd/c to handle paths with spaces in Windows
                args.add("\"");
            }

            // java
            String javaExePath;

            JDK jdk = build.getProject().getJDK();
            Computer computer = Computer.currentComputer();
            if (computer != null && jdk != null) { // just in case were not in a build
                // use node specific installers, etc
                jdk = jdk.forNode(computer.getNode(), listener);
            }

            if (jdk != null) {
                javaExePath = jdk.getHome() + "/bin/java";
            } else {
                javaExePath = "java";
            }
            args.add(javaExePath);

            splitAndAddArgs(env.expand(jvmFlags), args);
            splitAndAddArgs(env.expand(sbt.getSbtArguments()), args);
            splitAndAddArgs(env.expand(sbtFlags), args);

            // additionnal args from .sbtopts file
            FilePath sbtopts = build.getProject().getWorkspace().child(".sbtopts");
            if (sbtopts.exists()) {
                String argsToSplit = sbtopts.readToString();
                if (!StringUtils.isBlank(argsToSplit)) {
                    String[] split = argsToSplit.split("\\s+");
                    for (String flag : split) {
                        if (flag.startsWith("-J")) {
                          args.add(flag.substring(2));
                        } else {
                          args.add(flag);
                        }
                    }
                }
            }

            args.add("-jar");

            args.add(launcherPath);

            String subActions = new StrSubstitutor(env).replace(actions);
            for (String action : split(subActions)) {
                args.add(action);
            }

            if (!launcher.isUnix()) {
                args.add("\"");
            }
        }

        return args;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.