Last active
August 29, 2015 14:06
-
-
Save samkirton/8d8b2ba146969a613da1 to your computer and use it in GitHub Desktop.
Increment a maven POM minor version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xml.etree import ElementTree as ET | |
file = open('pom.xml') | |
# NOTE: edit the pom.xml manually to increase to a major version | |
minor_version_increment = 0.01 | |
ET.register_namespace("", "http://maven.apache.org/POM/4.0.0") | |
tree = ET.ElementTree() | |
tree.parse(file) | |
root = tree.getroot() | |
for child in root: | |
if child.tag == "{http://maven.apache.org/POM/4.0.0}version": | |
current_version = float(child.text) | |
new_version = current_version + minor_version_increment | |
child.text = str(new_version) | |
value = ET.tostring(root, encoding='utf8', method='xml') | |
file.close() | |
save = open('pom.xml','w') | |
save.write(value) | |
save.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment