Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick diff between pom dependencies
#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
from packaging import version
import sys
# files produced from pom.xml by
# mvn dependency:list -f pom.xml | grep "] " | sed 's/.*]\ \ \ \ //g' | sort | uniq
# arg1 - current file
# arg2 - "should-be" file
cur = open(sys.argv[1])
cur_d = {}
for line in cur:
line = line.strip()
elts = line.split(":")
if len(elts) == 5:
(group, artifact, jar, ver, goal) = elts
elif len(elts) == 6:
# com.google.api:gax-grpc:jar:testlib:1.60.1:test
(group, artifact, jar, ver, something, goal) = elts
print( "What does this mean %s" % line)
else:
print ("WTF is this %s" % line)
raise
key = "%s:%s" % (group, artifact)
if goal not in cur_d:
cur_d[goal] = {}
cur_d[goal][key] = ver
print ("Read %s goals into cur: %s" % (len(cur_d), cur_d.keys()))
should = open(sys.argv[2])
result = {}
for line in should:
line = line.strip()
elts = line.split(":")
if len(elts) == 5:
(group, artifact, jar, ver, goal) = elts
elif len(elts) == 6:
# com.google.api:gax-grpc:jar:testlib:1.60.1:test
(group, artifact, jar, ver, something, goal) = elts
print ("What does this mean %s" % line)
else:
print ("WTF is this %s" % line)
raise
key = "%s:%s" % (group, artifact)
key_ver = "%s:%s" % (key, ver)
# print "Checking if %s is in %s" % (key, goal)
if goal not in result:
result[goal] = []
if goal not in cur_d:
result[goal].append("Missing %s" % key_ver)
else:
if key not in cur_d[goal]:
result[goal].append("Missing %s" % key_ver)
else:
if cur_d[goal][key] != ver:
if version.parse( cur_d[goal][key]) < version.parse(ver):
result[goal].append("HAVE OLDER VERSION for %s: have %s, need %s" % (key, cur_d[goal][key], ver))
elif version.parse( cur_d[goal][key]) > version.parse(ver):
result[goal].append("PROBABLY OK: Have newer version for %s: have %s, need %s" % (key, cur_d[goal][key], ver))
for goal in result:
print ("")
print (goal)
print ("=======")
for msg in result[goal]:
print (msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment