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;
try
{
scmResult = provider.checkOut( repository, new ScmFileSet( checkoutDirectory ),
new ScmTag( releaseDescriptor.getScmReleaseLabel() ) );
}
catch ( ScmException e )
{
result.setResultCode( ReleaseResult.ERROR );
logError( result, e.getMessage() );
throw new ReleaseExecutionException( "An error is occurred in the checkout process: " + e.getMessage(), e );
}
String scmRelativePathProjectDirectory = scmResult.getRelativePathProjectDirectory();
if ( StringUtils.isEmpty( scmRelativePathProjectDirectory ) )
{
String basedir;
try
{
basedir = ReleaseUtil.getCommonBasedir( reactorProjects );
}
catch ( IOException e )
{
throw new ReleaseExecutionException( "Exception occurred while calculating common basedir: "
+ e.getMessage(), e );
}
String rootProjectBasedir = rootProject.getBasedir().getAbsolutePath();
try
{
if ( ReleaseUtil.isSymlink( rootProject.getBasedir() ) )
{
rootProjectBasedir = rootProject.getBasedir().getCanonicalPath();
}
}
catch ( IOException e )
{
throw new ReleaseExecutionException( e.getMessage(), e );
}
if ( rootProjectBasedir.length() > basedir.length() )
{
scmRelativePathProjectDirectory = rootProjectBasedir.substring( basedir.length() + 1 );
}