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