use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class HgUtils method buildCmd.
static Commandline buildCmd(File workingDir, String[] cmdAndArgs) throws ScmException {
Commandline cmd = new Commandline();
cmd.setExecutable(HgCommandConstants.EXEC);
cmd.addArguments(cmdAndArgs);
if (workingDir != null) {
cmd.setWorkingDirectory(workingDir.getAbsolutePath());
if (!workingDir.exists()) {
boolean success = workingDir.mkdirs();
if (!success) {
String msg = "Working directory did not exist" + " and it couldn't be created: " + workingDir;
throw new ScmException(msg);
}
}
}
return cmd;
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class ClearCaseEditCommand method createCheckinCurrentDirCommandLine.
public static Commandline createCheckinCurrentDirCommandLine(ScmFileSet scmFileSet) {
Commandline command = new Commandline();
File workingDirectory = scmFileSet.getBasedir();
command.setWorkingDirectory(workingDirectory.getAbsolutePath());
command.setExecutable("cleartool");
command.createArg().setValue("ci");
command.createArg().setValue("-nc");
command.createArg().setValue(".");
return command;
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class ClearCaseStatusCommand method createCommandLine.
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public static Commandline createCommandLine(ScmFileSet scmFileSet) {
Commandline command = new Commandline();
File workingDirectory = scmFileSet.getBasedir();
command.setWorkingDirectory(workingDirectory.getAbsolutePath());
command.setExecutable("cleartool");
command.createArg().setValue("lscheckout");
command.createArg().setValue("-cview");
command.createArg().setValue("-r");
command.createArg().setValue("-fmt");
command.createArg().setValue("%n\\n");
return command;
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class ClearCaseStatusCommand method executeStatusCommand.
/**
* {@inheritDoc}
*/
protected StatusScmResult executeStatusCommand(ScmProviderRepository scmProviderRepository, ScmFileSet scmFileSet) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing status command...");
}
Commandline cl = createCommandLine(scmFileSet);
ClearCaseStatusConsumer consumer = new ClearCaseStatusConsumer(getLogger(), scmFileSet.getBasedir());
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 StatusScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new StatusScmResult(cl.toString(), consumer.getCheckedOutFiles());
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class ClearCaseCheckInCommandTest method testCommand.
public void testCommand() throws Exception {
File file = new File("test.java");
ScmFileSet scmFileSet = new ScmFileSet(getWorkingDirectory(), file);
Commandline commandLine = ClearCaseCheckInCommand.createCommandLine(scmFileSet, "done some changes");
assertCommandLine("cleartool ci -c \"done some changes\" " + file.getAbsolutePath(), getWorkingDirectory(), commandLine);
}
Aggregations