1 package org.apache.maven.plugins.scm.release;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import org.dom4j.Node;
22
23 /**
24 *
25 *
26 * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
27 *
28 * @version $Id: SnapshotVersionTransformer.java 521198 2007-03-22 10:39:43Z ltheussl $
29 */
30 public class SnapshotVersionTransformer
31 extends AbstractPomTransformer
32 {
33
34
35
36
37 public String selectNodesXPathExpression()
38 {
39 return "/project";
40 }
41
42 public String selectNodeXPath()
43 {
44 return "currentVersion";
45 }
46
47 public String getNodeContent( Node node )
48 throws Exception
49 {
50 String currentVersion = node.selectSingleNode( selectNodeXPath() ).getText();
51
52 int i = currentVersion.indexOf( "-SNAPSHOT" );
53 if ( i > 0 )
54 {
55 currentVersion = currentVersion.substring( 0, i );
56 }
57
58 return currentVersion;
59 }
60
61 public void transformNode( Node node )
62 throws Exception
63 {
64 Node currentVersion = node.selectSingleNode( selectNodeXPath() );
65 currentVersion.setText( getNodeContent( node ) );
66 }
67
68 public Node getTransformedNode( Node node )
69 throws Exception
70 {
71 Node transformedNode = (Node) node.clone();
72 Node currentVersion = transformedNode.selectSingleNode( selectNodeXPath() );
73 currentVersion.setText( getNodeContent( transformedNode ) );
74
75 return transformedNode;
76 }
77 }