use of org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer in project maven-scm by apache.
the class TfsTagCommand method executeTagCommand.
protected ScmResult executeTagCommand(ScmProviderRepository r, ScmFileSet f, String tag, ScmTagParameters scmTagParameters) throws ScmException {
TfsCommand command = createCommand(r, f, tag, scmTagParameters);
StringStreamConsumer out = new StringStreamConsumer();
ErrorStreamConsumer err = new ErrorStreamConsumer();
int status = command.execute(out, err);
if (status != 0 || err.hasBeenFed()) {
return new TagScmResult(command.getCommandString(), "Error code for TFS label command - " + status, err.getOutput(), false);
}
List<ScmFile> files = new ArrayList<ScmFile>(f.getFileList().size());
for (File file : f.getFileList()) {
files.add(new ScmFile(file.getPath(), ScmFileStatus.TAGGED));
}
return new TagScmResult(command.getCommandString(), files);
}
use of org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer in project maven-scm by apache.
the class TfsBranchCommand method executeBranchCommand.
protected ScmResult executeBranchCommand(ScmProviderRepository r, ScmFileSet f, String branch, String message) throws ScmException {
TfsCommand command = createCommand(r, f, branch);
StringStreamConsumer out = new StringStreamConsumer();
ErrorStreamConsumer err = new ErrorStreamConsumer();
int status = command.execute(out, err);
getLogger().info("status of branch command is= " + status + "; err= " + err.getOutput());
if (status != 0 || err.hasBeenFed()) {
return new BranchScmResult(command.getCommandString(), "Error code for TFS branch command - " + status, err.getOutput(), false);
}
return new BranchScmResult(command.getCommandString(), new ArrayList<ScmFile>(0));
}
use of org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer in project maven-scm by apache.
the class TfsCommand method execute.
public int execute(StreamConsumer out, ErrorStreamConsumer err) throws ScmException {
info("Command line - " + getCommandString());
int status;
try {
status = CommandLineUtils.executeCommandLine(command, out, err);
} catch (CommandLineException e) {
throw new ScmException("Error while executing TFS command line - " + getCommandString(), e);
}
info("err - " + err.getOutput());
if (out instanceof StringStreamConsumer) {
StringStreamConsumer sc = (StringStreamConsumer) out;
debug(sc.getOutput());
}
if (out instanceof FileListConsumer) {
FileListConsumer f = (FileListConsumer) out;
for (Iterator<ScmFile> i = f.getFiles().iterator(); i.hasNext(); ) {
ScmFile file = i.next();
debug(file.getPath());
}
}
return status;
}
use of org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer in project maven-scm by apache.
the class ScmTestCase method execute.
/**
* Execute the command line
*
* @param workingDirectory not null
* @param executable not null, should be a system command
* @param arguments not null
* @throws Exception if any
* @see CommandLineUtils#executeCommandLine(Commandline, org.codehaus.plexus.util.cli.StreamConsumer,
* org.codehaus.plexus.util.cli.StreamConsumer)
*/
public static void execute(File workingDirectory, String executable, String arguments) throws Exception {
Commandline cl = new Commandline();
cl.setExecutable(executable);
cl.setWorkingDirectory(workingDirectory.getAbsolutePath());
cl.addArguments(CommandLineUtils.translateCommandline(arguments));
StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
System.out.println("Test command line: " + cl);
int exitValue = CommandLineUtils.executeCommandLine(cl, stdout, stderr);
if (debugExecute || exitValue != 0) {
System.err.println("-----------------------------------------");
System.err.println("Command line: " + cl);
System.err.println("Working directory: " + cl.getWorkingDirectory());
System.err.println("-----------------------------------------");
System.err.println("Standard output: ");
System.err.println("-----------------------------------------");
System.err.println(stdout.getOutput());
System.err.println("-----------------------------------------");
System.err.println("Standard error: ");
System.err.println("-----------------------------------------");
System.err.println(stderr.getOutput());
System.err.println("-----------------------------------------");
}
if (exitValue != 0) {
fail("Exit value wasn't 0, was:" + exitValue);
}
}
Aggregations