Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Read a pom.xml and get version or update it in Python
def managePom(update=False):
from xml.etree import ElementTree as et
ns = "http://maven.apache.org/POM/4.0.0"
et.register_namespace('', ns)
tree = et.ElementTree()
tree.parse('pom.xml')
p = tree.getroot().find("{%s}version" % ns)
if update:
p.text = update
tree.write('pom.xml')
else:
return p.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment