{
ScmTranslator translator = (ScmTranslator) scmTranslators.get( scmRepository.getProvider() );
boolean result = false;
if ( translator != null )
{
Scm scm = project.getOriginalModel().getScm();
if ( scm == null )
{
scm = project.getScm();
}
String tag = releaseDescriptor.getScmReleaseLabel();
String tagBase = releaseDescriptor.getScmTagBase();
// TODO: svn utils should take care of prepending this
if ( tagBase != null )
{
tagBase = "scm:svn:" + tagBase;
}
String workingDirectory =
ReleaseUtil.isSymlink( project.getBasedir() ) ? project.getBasedir().getCanonicalPath()
: project.getBasedir().getAbsolutePath();
int count =
ReleaseUtil.getBaseWorkingDirectoryParentCount( commonBasedir, workingDirectory );
if ( scm.getConnection() != null )
{
String rootUrl = ReleaseUtil.realignScmUrl( count, scm.getConnection() );
String subDirectoryTag = scm.getConnection().substring( rootUrl.length() );
if ( !subDirectoryTag.startsWith( "/" ) )
{
subDirectoryTag = "/" + subDirectoryTag;
}
String scmConnectionTag = tagBase;
if ( scmConnectionTag != null )
{
String trunkUrl = scm.getDeveloperConnection();
if ( trunkUrl == null )
{
trunkUrl = scm.getConnection();
}
scmConnectionTag = this.translateUrlPath( trunkUrl, tagBase, scm.getConnection() );
}
String value =
translator.translateTagUrl( scm.getConnection(), tag + subDirectoryTag, scmConnectionTag );
if ( !value.equals( scm.getConnection() ) )
{
rewriteElement( "connection", value, scmRoot, namespace );
result = true;
}
}
if ( scm.getDeveloperConnection() != null )
{
String rootUrl = ReleaseUtil.realignScmUrl( count, scm.getDeveloperConnection() );
String subDirectoryTag = scm.getDeveloperConnection().substring( rootUrl.length() );
if ( !subDirectoryTag.startsWith( "/" ) )
{
subDirectoryTag = "/" + subDirectoryTag;
}
String value =
translator.translateTagUrl( scm.getDeveloperConnection(), tag + subDirectoryTag, tagBase );
if ( !value.equals( scm.getDeveloperConnection() ) )
{
rewriteElement( "developerConnection", value, scmRoot, namespace );
result = true;
}
}
if ( scm.getUrl() != null )
{
String rootUrl = ReleaseUtil.realignScmUrl( count, scm.getUrl() );
String subDirectoryTag = scm.getUrl().substring( rootUrl.length() );
if ( !subDirectoryTag.startsWith( "/" ) )
{
subDirectoryTag = "/" + subDirectoryTag;
}
String tagScmUrl = tagBase;
if ( tagScmUrl != null )
{
String trunkUrl = scm.getDeveloperConnection();
if ( trunkUrl == null )
{
trunkUrl = scm.getConnection();
}
tagScmUrl = this.translateUrlPath( trunkUrl, tagBase, scm.getUrl() );
}
// use original tag base without protocol
String value = translator.translateTagUrl( scm.getUrl(), tag + subDirectoryTag, tagScmUrl );
if ( !value.equals( scm.getUrl() ) )
{
rewriteElement( "url", value, scmRoot, namespace );
result = true;
}
}
if ( tag != null )
{
String value = translator.resolveTag( tag );
if ( value != null && !value.equals( scm.getTag() ) )
{
rewriteElement( "tag", value, scmRoot, namespace );
result = true;
}
}