@@ -26,8 +26,17 @@ public void setVersion(final String value) throws Exception {
2626 final Document document = this .readDocument ();
2727
2828 final Node projectNode = this .getNode (document .getChildNodes (), "project" );
29- final Node versionNode = this .getNode (projectNode .getChildNodes (), "version" );
30- versionNode .setTextContent (value );
29+
30+ // Not multimodule with version in parent pom
31+ final Node versionNodeOpt = this .findNode (projectNode .getChildNodes (), "version" );
32+ if (versionNodeOpt != null ) {
33+ versionNodeOpt .setTextContent (value );
34+ } else {
35+ // Probably version in parent/version node
36+ final Node parentNode = this .getNode (projectNode .getChildNodes (), "parent" );
37+ final Node versionNode = this .getNode (parentNode .getChildNodes (), "version" );
38+ versionNode .setTextContent (value );
39+ }
3140
3241 this .saveDocument (document );
3342 }
@@ -47,7 +56,7 @@ private void saveDocument(final Node document) throws Exception {
4756 transformer .transform (source , result );
4857 }
4958
50- private Node getNode (final NodeList nodes , final String tagName ) {
59+ private Node findNode (final NodeList nodes , final String tagName ) {
5160 Node found = null ;
5261 for (int tagIndex = 0 ; tagIndex < nodes .getLength (); tagIndex ++) {
5362 final Node tag = nodes .item (tagIndex );
@@ -58,6 +67,11 @@ private Node getNode(final NodeList nodes, final String tagName) {
5867 found = tag ;
5968 }
6069 }
70+ return found ;
71+ }
72+
73+ private Node getNode (final NodeList nodes , final String tagName ) {
74+ Node found = findNode (nodes , tagName );
6175 if (found == null ) {
6276 throw new RuntimeException ("Cannot find " + tagName + " in " + nodes );
6377 }
0 commit comments