use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class CvsExeRemoveCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected RemoveScmResult executeCvsCommand(Commandline cl, List<ScmFile> removedFiles) throws ScmException {
CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
// TODO: actually it may have partially succeeded - should we cvs update the files and parse "A " responses?
if (exitCode != 0) {
return new RemoveScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
}
return new RemoveScmResult(cl.toString(), removedFiles);
}
use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class CvsExeTagCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected TagScmResult executeCvsCommand(Commandline cl) throws ScmException {
int exitCode;
CvsTagConsumer consumer = new CvsTagConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
try {
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
// TODO: Improve this error message
return new TagScmResult(cl.toString(), "The cvs tag command failed.", stderr.getOutput(), false);
}
return new TagScmResult(cl.toString(), consumer.getTaggedFiles());
}
use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class BootstrapMojo method runGoals.
/**
* @param relativePathProjectDirectory the project directory's path relative to the checkout
* directory; or "" if they are the same
* @throws MojoExecutionException if any
*/
private void runGoals(String relativePathProjectDirectory) throws MojoExecutionException {
Commandline cl = new Commandline();
try {
cl.addSystemEnvironment();
} catch (Exception e) {
throw new MojoExecutionException("Can't add system environment variables to mvn command line.", e);
}
cl.addEnvironment("MAVEN_TERMINATE_CMD", "on");
if (this.mavenHome == null) {
// none windows only
cl.setExecutable("mvn");
} else {
String mvnPath = this.mavenHome.getAbsolutePath() + "/bin/mvn";
if (Os.isFamily("windows")) {
String winMvnPath = mvnPath + ".cmd";
if (!new File(winMvnPath).exists()) {
winMvnPath = mvnPath + ".bat";
}
mvnPath = winMvnPath;
}
cl.setExecutable(mvnPath);
}
cl.setWorkingDirectory(determineWorkingDirectoryPath(//
this.getCheckoutDirectory(), relativePathProjectDirectory, goalsDirectory));
if (this.goals != null) {
String[] tokens = StringUtils.split(this.goals, ", ");
for (int i = 0; i < tokens.length; ++i) {
cl.createArg().setValue(tokens[i]);
}
}
if (!StringUtils.isEmpty(this.profiles)) {
cl.createArg().setValue("-P" + this.profiles);
}
StreamConsumer consumer = new DefaultConsumer();
try {
int result = CommandLineUtils.executeCommandLine(cl, consumer, consumer);
if (result != 0) {
throw new MojoExecutionException("Result of mvn execution is: \'" + result + "\'. Release failed.");
}
} catch (CommandLineException e) {
throw new MojoExecutionException("Can't run goal " + goals, e);
}
}
use of org.codehaus.plexus.util.cli.CommandLineException 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.CommandLineException in project maven-scm by apache.
the class VssCommandLineUtils method executeCommandline.
public static int executeCommandline(Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger) throws ScmException {
try {
if (logger.isInfoEnabled()) {
logger.info("Executing: " + cl);
logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
int exitcode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
if (logger.isDebugEnabled()) {
logger.debug("VSS Command Exit_Code: " + exitcode);
}
return exitcode;
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
}
Aggregations