Rewrite scm connections

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@178416 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-05-25 09:36:20 +00:00
parent 82a6d51998
commit f3346df4b8
2 changed files with 82 additions and 14 deletions

View File

@ -69,6 +69,10 @@ public class PrepareReleaseMojo
private String currentTag;
private String currentScmConnection;
private String currentScmDeveloperConnection;
protected void executeTask()
throws MojoExecutionException
{
@ -258,8 +262,20 @@ public class PrepareReleaseMojo
currentTag = model.getScm().getTag();
currentScmConnection = model.getScm().getConnection();
currentScmDeveloperConnection = model.getScm().getDeveloperConnection();
if ( model.getScm() != null )
{
model.getScm().setTag( getTagLabel() );
model.getScm().setConnection( rewriteScmConnection( model.getScm().getConnection(), getTagLabel() ) );
model.getScm().setDeveloperConnection( rewriteScmConnection( model.getScm().getDeveloperConnection(),
getTagLabel() ) );
}
try
{
Properties releaseProperties = new Properties();
@ -389,8 +405,15 @@ public class PrepareReleaseMojo
model.setVersion( projectVersion );
if ( model.getScm() != null )
{
model.getScm().setTag( currentTag );
model.getScm().setConnection( currentScmConnection );
model.getScm().setDeveloperConnection( currentScmDeveloperConnection );
}
PomTransformer transformer = new VersionTransformer();
transformer.setOutputFile( project.getFile() );
@ -525,4 +548,25 @@ public class PrepareReleaseMojo
throw new MojoExecutionException( "An error is occurred in the tag process.", e );
}
}
private String rewriteScmConnection( String scmConnection, String tag )
{
if ( scmConnection != null )
{
if ( scmConnection.startsWith( "svn" ) )
{
if ( scmConnection.endsWith( "trunk/") )
{
scmConnection = scmConnection.substring( 0, scmConnection.length() - "trunk/".length() );
}
if ( scmConnection.endsWith( "branches/") )
{
scmConnection = scmConnection.substring( 0, scmConnection.length() - "branches/".length() );
}
scmConnection += "tags/" + tag;
}
}
return scmConnection;
}
}

View File

@ -142,6 +142,8 @@ public class VersionTransformer
}
}
else
{
if ( getUpdatedModel().getScm() != null )
{
// Modify scm tag
Element scm = (Element) node;
@ -159,6 +161,28 @@ public class VersionTransformer
{
tag.setText( getUpdatedModel().getScm().getTag() );
}
// Modify scmConnections
Node connection = node.selectSingleNode( "connection" );
if ( connection != null )
{
if ( !connection.getText().equals( getUpdatedModel().getScm().getConnection() ) )
{
connection.setText( getUpdatedModel().getScm().getConnection() );
}
}
Node developerConnection = node.selectSingleNode( "developerConnection" );
if ( developerConnection != null )
{
if ( !developerConnection.getText().equals( getUpdatedModel().getScm().getDeveloperConnection() ) )
{
developerConnection.setText( getUpdatedModel().getScm().getDeveloperConnection() );
}
}
}
}
}