use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class IntegrityBlameCommand method doShellConnect.
/**
* Execute 'si connect' command in current shell.
*
* @param iRepo the Integrity repository instance.
* @param workingDirectory the SCM working directory.
* @throws ScmException if connect command failed.
*/
private void doShellConnect(IntegrityScmProviderRepository iRepo, ScmFileSet workingDirectory) throws ScmException {
Commandline shell = new Commandline();
shell.setWorkingDirectory(workingDirectory.getBasedir());
shell.setExecutable("si");
shell.createArg().setValue("connect");
shell.createArg().setValue("--hostname=" + iRepo.getHost());
shell.createArg().setValue("--port=" + iRepo.getPort());
shell.createArg().setValue("--user=" + iRepo.getUser());
shell.createArg().setValue("--batch");
shell.createArg().setValue("--password=" + iRepo.getPassword());
CommandLineUtils.StringStreamConsumer shellConsumer = new CommandLineUtils.StringStreamConsumer();
try {
getLogger().debug("Executing: " + CommandLineUtils.toString(shell.getCommandline()));
int exitCode = CommandLineUtils.executeCommandLine(shell, shellConsumer, shellConsumer);
if (exitCode != 0) {
throw new ScmException("Can't login to integrity. Message : " + shellConsumer.toString());
}
} catch (CommandLineException cle) {
getLogger().error("Command Line Connect Exception: " + cle.getMessage());
throw new ScmException("Can't login to integrity. Message : " + cle.getMessage());
}
}
use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class IntegrityBlameCommand method doShellAnnotate.
/**
* Execute 'si annotate' command in current shell and process output as {@link BlameScmResult} instance.
*
* @param iRepo the Integrity repository instance.
* @param workingDirectory the SCM working directory.
* @param filename the file name.
* @return the {@link BlameScmResult} instance.
*/
private BlameScmResult doShellAnnotate(IntegrityScmProviderRepository iRepo, ScmFileSet workingDirectory, String filename) {
BlameScmResult result;
Commandline shell = new Commandline();
shell.setWorkingDirectory(workingDirectory.getBasedir());
shell.setExecutable("si");
shell.createArg().setValue("annotate");
shell.createArg().setValue("--hostname=" + iRepo.getHost());
shell.createArg().setValue("--port=" + iRepo.getPort());
shell.createArg().setValue("--user=" + iRepo.getUser());
shell.createArg().setValue("--fields=date,revision,author");
shell.createArg().setValue('"' + filename + '"');
IntegrityBlameConsumer shellConsumer = new IntegrityBlameConsumer(getLogger());
try {
getLogger().debug("Executing: " + CommandLineUtils.toString(shell.getCommandline()));
int exitCode = CommandLineUtils.executeCommandLine(shell, shellConsumer, new CommandLineUtils.StringStreamConsumer());
boolean success = (exitCode == 0 ? true : false);
ScmResult scmResult = new ScmResult(shell.getCommandline().toString(), "", "Exit Code: " + exitCode, success);
return new BlameScmResult(shellConsumer.getBlameList(), scmResult);
} catch (CommandLineException cle) {
getLogger().error("Command Line Exception: " + cle.getMessage());
result = new BlameScmResult(shell.getCommandline().toString(), cle.getMessage(), "", false);
}
return result;
}
use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class JazzScmCommand method execute.
public int execute(StreamConsumer out, ErrorConsumer err) throws ScmException {
logInfoMessage("Executing: " + cryptPassword(fCommand));
if (fCommand.getWorkingDirectory() != null) {
logInfoMessage("Working directory: " + fCommand.getWorkingDirectory().getAbsolutePath());
}
int status = 0;
try {
status = CommandLineUtils.executeCommandLine(fCommand, out, err);
} catch (CommandLineException e) {
String errorOutput = err.getOutput();
if (errorOutput.length() > 0) {
logErrorMessage("Error: " + err.getOutput());
}
throw new ScmException("Error while executing Jazz SCM command line - " + getCommandString(), e);
}
String errorOutput = err.getOutput();
if (errorOutput.length() > 0) {
logErrorMessage("Error: " + err.getOutput());
}
return status;
}
use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class GitCommandLineUtils method execute.
public static int execute(Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger) throws ScmException {
if (logger.isInfoEnabled()) {
logger.info("Executing: " + cl);
logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
int exitCode;
try {
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
return exitCode;
}
use of org.codehaus.plexus.util.cli.CommandLineException in project unleash-maven-plugin by shillner.
the class BuildProject method execute.
@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
this.log.info("Starting release build.");
try {
InvocationRequest request = setupInvocationRequest();
Invoker invoker = setupInvoker();
InvocationResult result = invoker.execute(request);
if (result.getExitCode() != 0) {
CommandLineException executionException = result.getExecutionException();
if (executionException != null) {
throw new MojoFailureException("Error during project build: " + executionException.getMessage(), executionException);
} else {
throw new MojoFailureException("Error during project build: " + result.getExitCode());
}
}
} catch (MavenInvocationException e) {
throw new MojoFailureException(e.getMessage(), e);
}
}
Aggregations