Skip to content

Instantly share code, notes, and snippets.

@debedb
Created February 10, 2021 20:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debedb/48d9b4fba1a3aa33765ce1b6f36419b4 to your computer and use it in GitHub Desktop.
Save debedb/48d9b4fba1a3aa33765ce1b6f36419b4 to your computer and use it in GitHub Desktop.
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