use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class AbstractCvsCheckOutCommand method executeCommand.
@Override
public ScmResult executeCommand(ScmProviderRepository repo, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
ScmVersion version = parameters.getScmVersion(CommandParameter.SCM_VERSION, null);
boolean binary = parameters.getBoolean(CommandParameter.BINARY, false);
if (fileSet.getBasedir().exists()) {
try {
FileUtils.deleteDirectory(fileSet.getBasedir());
} catch (IOException e) {
if (getLogger().isWarnEnabled()) {
getLogger().warn("Can't delete " + fileSet.getBasedir().getAbsolutePath(), e);
}
}
}
CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
Commandline cl = CvsCommandUtils.getBaseCommand("checkout", repository, fileSet);
cl.setWorkingDirectory(fileSet.getBasedir().getParentFile().getAbsolutePath());
if (binary) {
cl.createArg().setValue("-kb");
}
if (version != null && !StringUtils.isEmpty(version.getName())) {
cl.createArg().setValue("-r");
cl.createArg().setValue(version.getName());
}
cl.createArg().setValue("-d");
cl.createArg().setValue(fileSet.getBasedir().getName());
cl.createArg().setValue(repository.getModule());
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + cl);
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
return executeCvsCommand(cl);
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class VssTagCommand method buildCmdLine.
public Commandline buildCmdLine(VssScmProviderRepository repo, ScmFileSet fileSet, String tagName, String message) throws ScmException {
Commandline command = new Commandline();
command.setWorkingDirectory(fileSet.getBasedir().getAbsolutePath());
try {
command.addSystemEnvironment();
} catch (Exception e) {
throw new ScmException("Can't add system environment.", e);
}
command.addEnvironment("SSDIR", repo.getVssdir());
String ssDir = VssCommandLineUtils.getSsDir();
command.setExecutable(ssDir + VssConstants.SS_EXE);
command.createArg().setValue(VssConstants.COMMAND_LABEL);
command.createArg().setValue(VssConstants.PROJECT_PREFIX + repo.getProject());
// User identification to get access to vss repository
if (repo.getUserPassword() != null) {
command.createArg().setValue(VssConstants.FLAG_LOGIN + repo.getUserPassword());
}
// Ignore: Do not ask for input under any circumstances.
command.createArg().setValue(VssConstants.FLAG_AUTORESPONSE_DEF);
command.createArg().setValue(VssConstants.FLAG_LABEL + tagName);
return command;
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class VssTagCommand method executeTagCommand.
/**
* @see org.apache.maven.scm.command.tag.AbstractTagCommand#executeTagCommand(org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet, java.lang.String, java.lang.String)
*/
protected ScmResult executeTagCommand(ScmProviderRepository repository, ScmFileSet fileSet, String tagName, String message) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing tag command...");
}
VssScmProviderRepository repo = (VssScmProviderRepository) repository;
Commandline cl = buildCmdLine(repo, fileSet, tagName, message);
VssTagConsumer consumer = new VssTagConsumer(repo, getLogger());
// TODO handle deleted files from VSS
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
}
exitCode = VssCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
if (exitCode != 0) {
String error = stderr.getOutput();
if (getLogger().isDebugEnabled()) {
getLogger().debug("VSS returns error: [" + error + "] return code: [" + exitCode + "]");
}
if (error.indexOf("A writable copy of") < 0) {
return new TagScmResult(cl.toString(), "The vss command failed.", error, false);
}
// print out the writable copy for manual handling
if (getLogger().isWarnEnabled()) {
getLogger().warn(error);
}
}
return new TagScmResult(cl.toString(), consumer.getUpdatedFiles());
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class VssUpdateCommand method buildCmdLine.
public Commandline buildCmdLine(VssScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version) throws ScmException {
Commandline command = new Commandline();
command.setWorkingDirectory(fileSet.getBasedir().getAbsolutePath());
try {
command.addSystemEnvironment();
} catch (Exception e) {
throw new ScmException("Can't add system environment.", e);
}
command.addEnvironment("SSDIR", repo.getVssdir());
String ssDir = VssCommandLineUtils.getSsDir();
command.setExecutable(ssDir + VssConstants.SS_EXE);
command.createArg().setValue(VssConstants.COMMAND_GET);
command.createArg().setValue(VssConstants.PROJECT_PREFIX + repo.getProject());
// User identification to get access to vss repository
if (repo.getUserPassword() != null) {
command.createArg().setValue(VssConstants.FLAG_LOGIN + repo.getUserPassword());
}
// Display the history of an entire project list
command.createArg().setValue(VssConstants.FLAG_RECURSION);
// Ignore: Do not ask for input under any circumstances.
command.createArg().setValue(VssConstants.FLAG_AUTORESPONSE_DEF);
// FIXME Update command only works if there is no file checked out
// or no file is dirty locally. It's better than overwriting
// checked out files
// Ignore: Do not touch local writable files.
command.createArg().setValue(VssConstants.FLAG_SKIP_WRITABLE);
if (version != null) {
command.createArg().setValue(VssConstants.FLAG_VERSION_LABEL + version);
}
return command;
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class VssAddCommandTest method testBuildCmdLine.
public void testBuildCmdLine() throws Exception {
ScmRepository repository = scmManager.makeScmRepository("scm:vss|username|password@C:/Program File/Visual Source Safe|D:/myProject");
File dir = getTestFile("target");
ScmFileSet fileSet = new ScmFileSet(dir);
VssAddCommand command = new VssAddCommand();
Commandline cl = command.buildCmdLine((VssScmProviderRepository) repository.getProviderRepository(), fileSet);
String ssPath = VssCommandLineUtils.getSsDir().replace('/', File.separatorChar);
assertCommandLine(ssPath + "ss Add -Yusername,password -I-", dir, cl);
}
Aggregations