{
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() ) )
{
// Another config spec is needed in this case.
//
// One option how to implement this would be to use a name convention for the config specs,
// e.g. the tag name could be appended to the original config spec name.
// If the config spec from the SCM URL would be \\myserver\configspecs\someproj.txt
// and the tag name would be mytag, the new config spec location could be
// \\myserver\configspecs\someproj-mytag.txt
//
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 );
}