mirror of https://github.com/apache/maven.git
Rewrite scm tag part in project file in prepare release phase.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@178323 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
551ab886d7
commit
82a6d51998
|
@ -67,6 +67,8 @@ public class PrepareReleaseMojo
|
||||||
|
|
||||||
private String userTag;
|
private String userTag;
|
||||||
|
|
||||||
|
private String currentTag;
|
||||||
|
|
||||||
protected void executeTask()
|
protected void executeTask()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
|
@ -254,6 +256,10 @@ public class PrepareReleaseMojo
|
||||||
|
|
||||||
model.setVersion( projectVersion );
|
model.setVersion( projectVersion );
|
||||||
|
|
||||||
|
currentTag = model.getScm().getTag();
|
||||||
|
|
||||||
|
model.getScm().setTag( getTagLabel() );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Properties releaseProperties = new Properties();
|
Properties releaseProperties = new Properties();
|
||||||
|
@ -383,6 +389,8 @@ public class PrepareReleaseMojo
|
||||||
|
|
||||||
model.setVersion( projectVersion );
|
model.setVersion( projectVersion );
|
||||||
|
|
||||||
|
model.getScm().setTag( currentTag );
|
||||||
|
|
||||||
PomTransformer transformer = new VersionTransformer();
|
PomTransformer transformer = new VersionTransformer();
|
||||||
|
|
||||||
transformer.setOutputFile( project.getFile() );
|
transformer.setOutputFile( project.getFile() );
|
||||||
|
|
|
@ -207,28 +207,14 @@ public abstract class AbstractPomTransformer
|
||||||
// Implementation
|
// Implementation
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public abstract String selectProjectNodeXPathExpression();
|
public abstract String selectProjectNodeXPathExpression();
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public abstract String selectDependenciesNodesXPathExpression();
|
public abstract String selectDependenciesNodesXPathExpression();
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public abstract String selectPluginsNodesXPathExpression();
|
public abstract String selectPluginsNodesXPathExpression();
|
||||||
|
|
||||||
/**
|
public abstract String selectScmTagNodesXPathExpression();
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
*/
|
|
||||||
public abstract void transformNode( Node node );
|
public abstract void transformNode( Node node );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -255,6 +241,8 @@ public abstract class AbstractPomTransformer
|
||||||
|
|
||||||
XPath pluginsXpath = new Dom4jXPath( selectPluginsNodesXPathExpression() );
|
XPath pluginsXpath = new Dom4jXPath( selectPluginsNodesXPathExpression() );
|
||||||
|
|
||||||
|
XPath scmXpath = new Dom4jXPath( selectScmTagNodesXPathExpression() );
|
||||||
|
|
||||||
List nodes = new ArrayList();
|
List nodes = new ArrayList();
|
||||||
|
|
||||||
nodes.addAll( pomXpath.selectNodes( getDocument() ) );
|
nodes.addAll( pomXpath.selectNodes( getDocument() ) );
|
||||||
|
@ -263,6 +251,8 @@ public abstract class AbstractPomTransformer
|
||||||
|
|
||||||
nodes.addAll( pluginsXpath.selectNodes( getDocument() ) );
|
nodes.addAll( pluginsXpath.selectNodes( getDocument() ) );
|
||||||
|
|
||||||
|
nodes.addAll( scmXpath.selectNodes( getDocument() ) );
|
||||||
|
|
||||||
setSelectedNodes( nodes );
|
setSelectedNodes( nodes );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,16 @@ public class VersionTransformer
|
||||||
return "/project/build/plugins/plugin";
|
return "/project/build/plugins/plugin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String selectScmTagNodesXPathExpression()
|
||||||
|
{
|
||||||
|
return "/project/scm/tag";
|
||||||
|
}
|
||||||
|
|
||||||
public void transformNode( Node node )
|
public void transformNode( Node node )
|
||||||
{
|
{
|
||||||
if ( selectProjectNodeXPathExpression().equals( node.getPath() ) )
|
if ( selectProjectNodeXPathExpression().equals( node.getPath() ) )
|
||||||
{
|
{
|
||||||
|
// Modify project version
|
||||||
Element project = (Element) node;
|
Element project = (Element) node;
|
||||||
|
|
||||||
Node version = node.selectSingleNode( "version" );
|
Node version = node.selectSingleNode( "version" );
|
||||||
|
@ -71,6 +77,7 @@ public class VersionTransformer
|
||||||
}
|
}
|
||||||
else if ( selectDependenciesNodesXPathExpression().equals( node.getPath() ) )
|
else if ( selectDependenciesNodesXPathExpression().equals( node.getPath() ) )
|
||||||
{
|
{
|
||||||
|
// Modify dependency version
|
||||||
Element dependency = (Element) node;
|
Element dependency = (Element) node;
|
||||||
|
|
||||||
Node groupId = node.selectSingleNode( "groupId" );
|
Node groupId = node.selectSingleNode( "groupId" );
|
||||||
|
@ -97,8 +104,9 @@ public class VersionTransformer
|
||||||
type.getText() ).getVersion() );
|
type.getText() ).getVersion() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if ( selectPluginsNodesXPathExpression().equals( node.getPath() ) )
|
||||||
{
|
{
|
||||||
|
// Modify plugin version
|
||||||
Element plugin = (Element) node;
|
Element plugin = (Element) node;
|
||||||
|
|
||||||
Node groupId = node.selectSingleNode( "groupId" );
|
Node groupId = node.selectSingleNode( "groupId" );
|
||||||
|
@ -133,6 +141,25 @@ public class VersionTransformer
|
||||||
plugin.addElement( "version" ).addText( p.getVersion() );
|
plugin.addElement( "version" ).addText( p.getVersion() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Modify scm tag
|
||||||
|
Element scm = (Element) node;
|
||||||
|
|
||||||
|
Node tag = node.selectSingleNode( "tag" );
|
||||||
|
|
||||||
|
if ( tag == null )
|
||||||
|
{
|
||||||
|
if ( !"HEAD".equals( getUpdatedModel().getScm().getTag() ) )
|
||||||
|
{
|
||||||
|
scm.addElement( "tag" ).addText( getUpdatedModel().getScm().getTag() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tag.setText( getUpdatedModel().getScm().getTag() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dependency getDependency( String groupId, String artifactId, String type )
|
private Dependency getDependency( String groupId, String artifactId, String type )
|
||||||
|
|
Loading…
Reference in New Issue