use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class ClearCaseUpdateCommand method executeUpdateCommand.
/**
* {@inheritDoc}
*/
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing update command...");
}
Commandline cl = createCommandLine(fileSet);
ClearCaseUpdateConsumer consumer = new ClearCaseUpdateConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
}
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing clearcase command.", ex);
}
if (exitCode != 0) {
return new UpdateScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new UpdateScmResult(cl.toString(), consumer.getUpdatedFiles());
}
use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class ClearCaseAddCommand method executeAddCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeAddCommand(ScmProviderRepository scmProviderRepository, ScmFileSet scmFileSet, String string, boolean b) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing add command...");
}
Commandline cl = createCommandLine(scmFileSet);
ClearCaseAddConsumer consumer = new ClearCaseAddConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
// First we need to 'check out' the current directory
Commandline checkoutCurrentDirCommandLine = ClearCaseEditCommand.createCheckoutCurrentDirCommandLine(scmFileSet);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + checkoutCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkoutCurrentDirCommandLine.toString());
}
exitCode = CommandLineUtils.executeCommandLine(checkoutCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
if (exitCode == 0) {
// Then we add the file
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
}
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
if (exitCode == 0) {
// Then we check in the current directory again.
Commandline checkinCurrentDirCommandLine = ClearCaseEditCommand.createCheckinCurrentDirCommandLine(scmFileSet);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + checkinCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkinCurrentDirCommandLine.toString());
}
exitCode = CommandLineUtils.executeCommandLine(checkinCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
}
}
} catch (CommandLineException ex) {
throw new ScmException("Error while executing clearcase command.", ex);
}
if (exitCode != 0) {
return new StatusScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new StatusScmResult(cl.toString(), consumer.getAddedFiles());
}
use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class ClearCaseCheckOutCommand method executeCheckOutCommand.
// ----------------------------------------------------------------------
// AbstractCheckOutCommand Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing checkout command...");
}
ClearCaseScmProviderRepository repo = (ClearCaseScmProviderRepository) repository;
File workingDirectory = fileSet.getBasedir();
if (version != null && getLogger().isDebugEnabled()) {
getLogger().debug(version.getType() + ": " + version.getName());
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Running with CLEARCASE " + settings.getClearcaseType());
}
ClearCaseCheckOutConsumer consumer = new ClearCaseCheckOutConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
Commandline cl;
String projectDirectory = "";
try {
// Since clearcase only wants to checkout to a non-existent directory, first delete the working dir
// if it already exists
FileUtils.deleteDirectory(workingDirectory);
// First create the view
String viewName = getUniqueViewName(repo, workingDirectory.getAbsolutePath());
String streamIdentifier = getStreamIdentifier(repo.getStreamName(), repo.getVobName());
cl = createCreateViewCommandLine(workingDirectory, viewName, streamIdentifier);
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
}
exitCode = CommandLineUtils.executeCommandLine(cl, new CommandLineUtils.StringStreamConsumer(), stderr);
if (exitCode == 0) {
File configSpecLocation;
if (!repo.isAutoConfigSpec()) {
configSpecLocation = repo.getConfigSpec();
if (version != null && StringUtils.isNotEmpty(version.getName())) {
//
throw new UnsupportedOperationException("Building on a label not supported with user-specified config specs");
}
} else {
// write config spec to temp file
String configSpec;
if (!repo.hasElements()) {
configSpec = createConfigSpec(repo.getLoadDirectory(), version);
} else {
configSpec = createConfigSpec(repo.getLoadDirectory(), repo.getElementName(), version);
}
if (getLogger().isInfoEnabled()) {
getLogger().info("Created config spec for view '" + viewName + "':\n" + configSpec);
}
configSpecLocation = writeTemporaryConfigSpecFile(configSpec, viewName);
// When checking out from ClearCase, the directory structure of the
// SCM system is repeated within the checkout directory. E.g. if you check out the
// project "my/project" to "/some/dir", the project sources are actually checked out
// to "my/project/some/dir".
projectDirectory = repo.getLoadDirectory();
// strip off leading / to make the path relative
if (projectDirectory.startsWith("/")) {
projectDirectory = projectDirectory.substring(1);
}
}
cl = createUpdateConfigSpecCommandLine(workingDirectory, configSpecLocation, viewName);
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
}
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
}
} catch (CommandLineException ex) {
throw new ScmException("Error while executing clearcase command.", ex);
} catch (IOException ex) {
throw new ScmException("Error while deleting working directory.", ex);
}
if (exitCode != 0) {
return new CheckOutScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new CheckOutScmResult(cl.toString(), consumer.getCheckedOutFiles(), projectDirectory);
}
use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class CvsExeBlameCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected BlameScmResult executeCvsCommand(Commandline cl, CvsScmProviderRepository repository) throws ScmException {
CvsBlameConsumer consumer = new CvsBlameConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing cvs command.", ex);
}
if (exitCode != 0) {
return new BlameScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
}
return new BlameScmResult(cl.toString(), consumer.getLines());
}
use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.
the class CvsExeCheckOutCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected CheckOutScmResult executeCvsCommand(Commandline cl) throws ScmException {
CvsCheckOutConsumer consumer = new CvsCheckOutConsumer(getLogger());
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);
}
if (exitCode != 0) {
return new CheckOutScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
}
return new CheckOutScmResult(cl.toString(), consumer.getCheckedOutFiles());
}
Aggregations