use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class ClearCaseBlameCommand method executeBlameCommand.
public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing blame command...");
}
Commandline cl = createCommandLine(workingDirectory.getBasedir(), filename);
ClearCaseBlameConsumer consumer = new ClearCaseBlameConsumer(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 cvs command.", ex);
}
if (exitCode != 0) {
return new BlameScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new BlameScmResult(cl.toString(), consumer.getLines());
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class ClearCaseChangeLogCommand method executeChangeLogCommand.
// ----------------------------------------------------------------------
// AbstractChangeLogCommand Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
protected ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing changelog command...");
}
Commandline cl = createCommandLine(fileSet.getBasedir(), branch, startDate);
ClearCaseChangeLogConsumer consumer = new ClearCaseChangeLogConsumer(getLogger(), datePattern);
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 cvs command.", ex);
}
if (exitCode != 0) {
return new ChangeLogScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new ChangeLogScmResult(cl.toString(), new ChangeLogSet(consumer.getModifications(), startDate, endDate));
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class ClearCaseCheckInCommand method executeCheckInCommand.
// ----------------------------------------------------------------------
// AbstractCheckOutCommand Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing checkin command...");
}
Commandline cl = createCommandLine(fileSet, message);
ClearCaseCheckInConsumer consumer = new ClearCaseCheckInConsumer(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 CheckInScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new CheckInScmResult(cl.toString(), consumer.getCheckedInFiles());
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class ClearCaseCheckInCommand method createCommandLine.
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public static Commandline createCommandLine(ScmFileSet scmFileSet, String message) throws ScmException {
Commandline command = new Commandline();
File workingDirectory = scmFileSet.getBasedir();
command.setWorkingDirectory(workingDirectory.getAbsolutePath());
command.setExecutable("cleartool");
command.createArg().setValue("ci");
if (message != null) {
command.createArg().setValue("-c");
command.createArg().setLine("\"" + message + "\"");
} else {
command.createArg().setValue("-nc");
}
List<File> files = scmFileSet.getFileList();
if (files.isEmpty()) {
throw new ScmException("There are no files in the fileset to check in!");
}
for (File file : files) {
command.createArg().setValue(file.getAbsolutePath());
}
return command;
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class ClearCaseStatusCommandTest method testCommand.
public void testCommand() throws Exception {
ScmFileSet scmFileSet = new ScmFileSet(getWorkingDirectory(), new File("test.java"));
Commandline commandLine = ClearCaseStatusCommand.createCommandLine(scmFileSet);
assertCommandLine("cleartool lscheckout -cview -r -fmt %n\\n", getWorkingDirectory(), commandLine);
}
Aggregations