mirror of https://github.com/apache/maven.git
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:
parent
82a6d51998
commit
f3346df4b8
|
@ -69,6 +69,10 @@ public class PrepareReleaseMojo
|
||||||
|
|
||||||
private String currentTag;
|
private String currentTag;
|
||||||
|
|
||||||
|
private String currentScmConnection;
|
||||||
|
|
||||||
|
private String currentScmDeveloperConnection;
|
||||||
|
|
||||||
protected void executeTask()
|
protected void executeTask()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
|
@ -258,7 +262,19 @@ public class PrepareReleaseMojo
|
||||||
|
|
||||||
currentTag = model.getScm().getTag();
|
currentTag = model.getScm().getTag();
|
||||||
|
|
||||||
model.getScm().setTag( getTagLabel() );
|
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
|
try
|
||||||
{
|
{
|
||||||
|
@ -389,7 +405,14 @@ public class PrepareReleaseMojo
|
||||||
|
|
||||||
model.setVersion( projectVersion );
|
model.setVersion( projectVersion );
|
||||||
|
|
||||||
model.getScm().setTag( currentTag );
|
if ( model.getScm() != null )
|
||||||
|
{
|
||||||
|
model.getScm().setTag( currentTag );
|
||||||
|
|
||||||
|
model.getScm().setConnection( currentScmConnection );
|
||||||
|
|
||||||
|
model.getScm().setDeveloperConnection( currentScmDeveloperConnection );
|
||||||
|
}
|
||||||
|
|
||||||
PomTransformer transformer = new VersionTransformer();
|
PomTransformer transformer = new VersionTransformer();
|
||||||
|
|
||||||
|
@ -525,4 +548,25 @@ public class PrepareReleaseMojo
|
||||||
throw new MojoExecutionException( "An error is occurred in the tag process.", e );
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,21 +143,45 @@ public class VersionTransformer
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Modify scm tag
|
if ( getUpdatedModel().getScm() != null )
|
||||||
Element scm = (Element) node;
|
|
||||||
|
|
||||||
Node tag = node.selectSingleNode( "tag" );
|
|
||||||
|
|
||||||
if ( tag == null )
|
|
||||||
{
|
{
|
||||||
if ( !"HEAD".equals( getUpdatedModel().getScm().getTag() ) )
|
// Modify scm tag
|
||||||
|
Element scm = (Element) node;
|
||||||
|
|
||||||
|
Node tag = node.selectSingleNode( "tag" );
|
||||||
|
|
||||||
|
if ( tag == null )
|
||||||
{
|
{
|
||||||
scm.addElement( "tag" ).addText( getUpdatedModel().getScm().getTag() );
|
if ( !"HEAD".equals( getUpdatedModel().getScm().getTag() ) )
|
||||||
|
{
|
||||||
|
scm.addElement( "tag" ).addText( getUpdatedModel().getScm().getTag() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tag.setText( getUpdatedModel().getScm().getTag() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue