public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment,
List<MavenProject> reactorProjects )
throws ReleaseExecutionException, ReleaseFailureException
{
ReleaseResult relResult = new ReleaseResult();
validateConfiguration( releaseDescriptor );
if ( releaseDescriptor.getWaitBeforeTagging() > 0 )
{
logInfo( relResult, "Waiting for " + releaseDescriptor.getWaitBeforeTagging()
+ " seconds before tagging the release." );
try
{
Thread.sleep( 1000L * releaseDescriptor.getWaitBeforeTagging() );
}
catch ( InterruptedException e )
{
// Ignore
}
}
logInfo( relResult, "Tagging release with the label " + releaseDescriptor.getScmReleaseLabel() + "..." );
ReleaseDescriptor basedirAlignedReleaseDescriptor =
ReleaseUtil.createBasedirAlignedReleaseDescriptor( releaseDescriptor, reactorProjects );
ScmRepository repository;
ScmProvider provider;
try
{
repository =
scmRepositoryConfigurator.getConfiguredRepository( basedirAlignedReleaseDescriptor.getScmSourceUrl(),
releaseDescriptor,
releaseEnvironment.getSettings() );
repository.getProviderRepository().setPushChanges( releaseDescriptor.isPushChanges() );
provider = scmRepositoryConfigurator.getRepositoryProvider( repository );
}
catch ( ScmRepositoryException e )
{
throw new ReleaseScmRepositoryException( e.getMessage(), e.getValidationMessages() );
}
catch ( NoSuchScmProviderException e )
{
throw new ReleaseExecutionException( "Unable to configure SCM repository: " + e.getMessage(), e );
}
TagScmResult result;
try
{
// TODO: want includes/excludes?
ScmFileSet fileSet = new ScmFileSet( new File( basedirAlignedReleaseDescriptor.getWorkingDirectory() ) );
String tagName = releaseDescriptor.getScmReleaseLabel();
ScmTagParameters scmTagParameters =
new ScmTagParameters( releaseDescriptor.getScmCommentPrefix() + "copy for tag " + tagName );
scmTagParameters.setRemoteTagging( releaseDescriptor.isRemoteTagging() );
scmTagParameters.setScmRevision( releaseDescriptor.getScmReleasedPomRevision() );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug(
"ScmTagPhase :: scmTagParameters remotingTag " + releaseDescriptor.isRemoteTagging() );
getLogger().debug(
"ScmTagPhase :: scmTagParameters scmRevision " + releaseDescriptor.getScmReleasedPomRevision() );
getLogger().debug( "ScmTagPhase :: fileSet " + fileSet );
}
result = provider.tag( repository, fileSet, tagName, scmTagParameters );
}
catch ( ScmException e )
{
throw new ReleaseExecutionException( "An error is occurred in the tag process: " + e.getMessage(), e );
}
if ( !result.isSuccess() )
{
throw new ReleaseScmCommandException( "Unable to tag SCM", result );
}
relResult.setResultCode( ReleaseResult.SUCCESS );
return relResult;
}