Package net.sourceforge.cruisecontrol.util

Examples of net.sourceforge.cruisecontrol.util.Commandline


     * For example:
     *
     * 'svn update --non-interactive filename'
     */
    Commandline buildUpdateCommand() throws CruiseControlException {
        Commandline command = new Commandline();
        command.setExecutable("svn");

        if (localWorkingCopy != null) {
            command.setWorkingDirectory(localWorkingCopy);
        }

        command.createArgument().setValue("update");
        command.createArgument().setValue("--non-interactive");
        if (userName != null) {
            command.createArgument().setValue("--username");
            command.createArgument().setValue(userName);
        }
        if (password != null) {
            command.createArgument().setValue("--password");
            command.createArgument().setValue(password);
        }
        if (fileName != null) {
            command.createArgument().setValue(fileName);
        }

        LOG.debug("SVNBootstrapper: Executing command = " + command);

        return command;
View Full Code Here


     *
     * @return Commandline holding command to be executed
     * @throws CruiseControlException on unquotable attributes
     */
    public Commandline buildCommandline() throws CruiseControlException {
        Commandline cmdLine = new Commandline();

        if (useScript) {
            cmdLine.setExecutable(antScript);
        } else {
            if (isWindows) {
                cmdLine.setExecutable("java.exe");
            } else {
                cmdLine.setExecutable("java");
            }
            for (Iterator argsIterator = args.iterator(); argsIterator.hasNext(); ) {
                String arg = ((AntBuilder.JVMArg) argsIterator.next()).getArg();
                // empty args may break the command line
                if (arg != null && arg.length() > 0) {
                    cmdLine.createArgument().setValue(arg);
                }
            }

            cmdLine.createArgument().setValue("-classpath");
            cmdLine.createArgument().setValue(getAntLauncherJarLocation(systemClassPath, isWindows));
            cmdLine.createArgument().setValue("org.apache.tools.ant.launch.Launcher");
            cmdLine.createArgument().setValue("-lib");
            cmdLine.createArgument().setValue(systemClassPath);
        }

        if (useLogger) {
            cmdLine.createArgument().setValue("-logger");
            cmdLine.createArgument().setValue(getLoggerClassName());
            cmdLine.createArgument().setValue("-logfile");
            cmdLine.createArgument().setValue(tempFileName);
        } else {
            cmdLine.createArgument().setValue("-listener");
            cmdLine.createArgument().setValue(getLoggerClassName());
            cmdLine.createArgument().setValue("-DXmlLogger.file=" + tempFileName);
        }

        // -debug and -quiet only affect loggers, not listeners: when we use the loggerClassName as
        // a listener, they will affect the default logger that writes to the console
        if (useDebug) {
            cmdLine.createArgument().setValue("-debug");
        } else if (useQuiet) {
            cmdLine.createArgument().setValue("-quiet");
        }

        for (Iterator propertiesIter = buildProperties.entrySet().iterator(); propertiesIter.hasNext(); ) {
            Map.Entry property = (Map.Entry) propertiesIter.next();
            String value = (String) property.getValue();
            if (!"".equals(value)) {
                cmdLine.createArgument().setValue("-D" + property.getKey() + "=" + value);
            }
        }

        for (Iterator antPropertiesIterator = properties.iterator(); antPropertiesIterator.hasNext(); ) {
            Property property = (Property) antPropertiesIterator.next();
            cmdLine.createArgument().setValue("-D" + property.getName() + "=" + property.getValue());
        }

        cmdLine.createArgument().setValue("-buildfile");
        cmdLine.createArgument().setValue(buildFile);

        StringTokenizer targets = new StringTokenizer(target);
        while (targets.hasMoreTokens()) {
            cmdLine.createArgument().setValue(targets.nextToken());
        }
        return cmdLine;
    }
View Full Code Here

    /**
     *  Update the specified file.
     */
    public void bootstrap() {
        try {
            Commandline commandLine = buildUpdateCommand();
            Process p = commandLine.execute();
            final boolean autoFlushOn = true;
            StreamPumper errorPumper =
                new StreamPumper(p.getErrorStream(), new PrintWriter(System.err, autoFlushOn));
            StreamPumper outPumper = new StreamPumper(p.getInputStream(), new PrintWriter(System.out, autoFlushOn));
            Thread errorPumperThread = new Thread(errorPumper);
View Full Code Here

                        + localWorkingCopy + ">");
        }
    }

    protected Commandline buildUpdateCommand() throws CruiseControlException {
        Commandline commandLine = new Commandline();

        if (localWorkingCopy != null) {
            commandLine.setWorkingDirectory(localWorkingCopy);
        }       

        commandLine.setExecutable("cvs");

        if (cvsroot != null) {
            commandLine.createArgument().setValue("-d");
            commandLine.createArgument().setValue(cvsroot);
        }
        commandLine.createArgument().setValue("update");
       
        StringBuffer flags = new StringBuffer("-dP");
        if (resetStickyTags) {
            flags.append("A");
        }
        if (overwriteChanges) {
            flags.append("C");
        }
        commandLine.createArgument().setValue(flags.toString());

        if (filename != null) {
            commandLine.createArgument().setValue(filename);
        }

        return commandLine;
    }
View Full Code Here

    /**
     *  Update the specified file.
     */
    public void bootstrap() {
        Commandline commandLine = buildUpdateCommand();

        log.debug("Executing: " + commandLine);
        try {
            Process p = Runtime.getRuntime().exec(commandLine.getCommandline());
            StreamPumper errorPumper =
                new StreamPumper(p.getErrorStream(), new PrintWriter(System.err, true));
            new Thread(errorPumper).start();
            p.waitFor();
            p.getInputStream().close();
View Full Code Here

    public void validate() throws CruiseControlException {
        ValidationHelper.assertIsSet(filename, "file", this.getClass());
    }

    protected Commandline buildUpdateCommand() {
        Commandline commandLine = new Commandline();
        commandLine.setExecutable("cleartool");

        commandLine.createArgument().setValue("update");
        commandLine.createArgument().setValue("-force");
        commandLine.createArgument().setValue("-log");
        commandLine.createArgument().setValue(isWindows() ? "NUL" : "/dev/null");
        commandLine.createArgument().setValue(getFullPathFileName());

        return commandLine;
    }
View Full Code Here

    public void setFiles(String files) {
        filenames = files;
    }

    public void bootstrap() throws CruiseControlException {
        Commandline args = buildCheckoutCommand();
        int retVal = StarTeamCmd.run(args.getCommandline());
        if (retVal != 0) {
            throw new CruiseControlException("Error executing StarTeam checkout command: " + args.toString());
        }
    }
View Full Code Here

            "'files', 'username', 'password','server', 'port', 'project', 'view' and 'folder'"
              + " are all required for StarTeamBootstrapper");
    }

    private Commandline buildCheckoutCommand() {
        Commandline commandLine = new Commandline();
        commandLine.createArgument().setValue("co");
        commandLine.createArgument().setValue("-p");
        commandLine.createArgument().setValue(
            username
                + ':'
                + password
                + '@'
                + servername
                + ':'
                + serverport
                + '/'
                + projectname
                + '/'
                + viewname
                + '/'
                + foldername);
        if (localfoldername != null) {
            commandLine.createArgument().setValue("-fp");
            commandLine.createArgument().setValue(localfoldername);
        }
        commandLine.createArgument().setValue("-o");
        commandLine.createArgument().setValue("-x");
        commandLine.createArgument().setLine(filenames);
        return commandLine;
    }
View Full Code Here

    /**
     * p4 -s [-c client] [-p port] [-u user] changes -s submitted [view@lastBuildTime@now]
     */
    public Commandline buildChangesCommand(Date lastBuildTime, Date now) {
        Commandline commandLine = buildBaseP4Command();

        //        execP4Command("changes -m 1 -s submitted " + _P4View,

        commandLine.createArgument().setValue("changes");
        commandLine.createArgument().setValue("-s");
        commandLine.createArgument().setValue("submitted");
        commandLine.createArgument().setValue(
            p4View
                + "@"
                + P4_REVISION_DATE.format(lastBuildTime)
                + ",@"
                + P4_REVISION_DATE.format(now));
View Full Code Here

    /**
     * p4 -s [-c client] [-p port] [-u user] describe -s [change number]
     */
    public Commandline buildDescribeCommand(String[] changelistNumbers) {
        Commandline commandLine = buildBaseP4Command();

        //        execP4Command("describe -s " + changeNumber.toString(),

        commandLine.createArgument().setValue("describe");
        commandLine.createArgument().setValue("-s");

        for (int i = 0; i < changelistNumbers.length; i++) {
            commandLine.createArgument().setValue(changelistNumbers[i]);
        }

        return commandLine;
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.cruisecontrol.util.Commandline

Copyright © 2018 www.massapicom. 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.