Skip to content

Instantly share code, notes, and snippets.

@ericcitaire
Created December 21, 2015 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericcitaire/f8b230fafb87d90de92b to your computer and use it in GitHub Desktop.
Save ericcitaire/f8b230fafb87d90de92b to your computer and use it in GitHub Desktop.
Prints the pom version
#!/usr/bin/env python
import sys
import xml.etree.ElementTree as ET
for arg in sys.argv[1:]:
elements = ET.parse(arg).findall("./pom:version", {'pom': 'http://maven.apache.org/POM/4.0.0'})
if len(elements) == 1:
print elements[0].text
elif len(elements) == 0:
raise Exception('no version found')
else:
raise Exception('more than one version found')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment