use of org.apache.maven.scm.provider.clearcase.repository.ClearCaseScmProviderRepository 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);
}
Aggregations