Skip to content

Instantly share code, notes, and snippets.

@dizzythinks
Created November 10, 2017 10:48
  • Star 6 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dizzythinks/f3bb37fd8ab1484bfec79d39ad8a92d3 to your computer and use it in GitHub Desktop.
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
@gaborgsomogyi
Copy link

Helped me out, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment