ReleaseResult result = new ReleaseResult();
logInfo( result, "Checking out the project to perform the release ..." );
ScmRepository repository;
ScmProvider provider;
try
{
repository = scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor,
releaseEnvironment.getSettings() );
provider = scmRepositoryConfigurator.getRepositoryProvider( repository );
}
catch ( ScmRepositoryException e )
{
result.setResultCode( ReleaseResult.ERROR );
logError( result, e.getMessage() );
throw new ReleaseScmRepositoryException( e.getMessage(), e.getValidationMessages() );
}
catch ( NoSuchScmProviderException e )
{
result.setResultCode( ReleaseResult.ERROR );
logError( result, e.getMessage() );
throw new ReleaseExecutionException( "Unable to configure SCM repository: " + e.getMessage(), e );
}
MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
// TODO: sanity check that it is not . or .. or lower
File checkoutDirectory;
if ( StringUtils.isEmpty( releaseDescriptor.getCheckoutDirectory() ) )
{
checkoutDirectory = new File( rootProject.getFile().getParentFile(), "target/checkout" );
releaseDescriptor.setCheckoutDirectory( checkoutDirectory.getAbsolutePath() );
}
else
{
checkoutDirectory = new File( releaseDescriptor.getCheckoutDirectory() );
}
if ( checkoutDirectory.exists() )
{
try
{
FileUtils.deleteDirectory( checkoutDirectory );
}
catch ( IOException e )
{
result.setResultCode( ReleaseResult.ERROR );
logError( result, e.getMessage() );
throw new ReleaseExecutionException( "Unable to remove old checkout directory: " + e.getMessage(), e );
}
}
checkoutDirectory.mkdirs();
CheckOutScmResult scmResult;
scmResult = provider.checkOut( repository, new ScmFileSet( checkoutDirectory ),
new ScmTag( releaseDescriptor.getScmReleaseLabel() ) );
if ( releaseDescriptor.isLocalCheckout() && !scmResult.isSuccess() )
{
// this is not beautiful but needed to indicate that the execute() method