private boolean copyUpdated = false;
public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, Settings settings, List reactorProjects )
throws ReleaseExecutionException, ReleaseFailureException
{
ReleaseResult relResult = new ReleaseResult();
logInfo( relResult, "Updating local copy against the scm..." );
ScmRepository repository;
ScmProvider provider;
try
{
repository = scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, settings );
provider = scmRepositoryConfigurator.getRepositoryProvider( repository );
}
catch ( ScmRepositoryException e )
{
throw new ReleaseScmRepositoryException(
e.getMessage() + " for URL: " + releaseDescriptor.getScmSourceUrl(), e.getValidationMessages() );
}
catch ( NoSuchScmProviderException e )
{
throw new ReleaseExecutionException( "Unable to configure SCM repository: " + e.getMessage(), e );
}
UpdateScmResult updateScmResult = null;
CheckOutScmResult checkOutScmResult = null;
File workingDirectory = new File( releaseDescriptor.getWorkingDirectory() );
try
{
if ( !workingDirectory.exists() )
{
workingDirectory.mkdirs();
}
if( workingDirectory.listFiles().length > 1 )
{
updateScmResult = provider.update( repository, new ScmFileSet( workingDirectory ), (ScmVersion) null );
}
else
{
checkOutScmResult = provider.checkOut( repository, new ScmFileSet( workingDirectory ) );
}
}
catch ( ScmException e )
{
throw new ReleaseExecutionException( "An error occurred while updating your local copy: " + e.getMessage(),
e );
}
if ( updateScmResult != null )
{
if( !updateScmResult.isSuccess() )
{
throw new ReleaseScmCommandException( "Unable to update current working copy", updateScmResult );
}
copyUpdated = updateScmResult.getUpdatedFiles().size() > 0;
}
else
{
if( !checkOutScmResult.isSuccess() )
{
throw new ReleaseScmCommandException( "Unable to checkout project", checkOutScmResult );
}
copyUpdated = checkOutScmResult.getCheckedOutFiles().size() > 0;
}
relResult.setResultCode( ReleaseResult.SUCCESS );
return relResult;
}