Skip to content

Instantly share code, notes, and snippets.

@redigaffi
Created September 10, 2019 09:20
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 redigaffi/6948ab891fcc8c79506800f59c3312bb to your computer and use it in GitHub Desktop.
Save redigaffi/6948ab891fcc8c79506800f59c3312bb to your computer and use it in GitHub Desktop.
Human readable list of Java dependencies
import xml.etree.ElementTree as ET
root = ET.parse('/home/jordi/IdeaProjects/backendapi/pom.xml').getroot()
dependencies = root.findall('*/{http://maven.apache.org/POM/4.0.0}dependency')
dependency_list = {}
for dependency in dependencies:
groupId = dependency.find('{http://maven.apache.org/POM/4.0.0}groupId').text
artifact = dependency.find('{http://maven.apache.org/POM/4.0.0}artifactId').text
try:
dependency_list[groupId].append(artifact)
except:
dependency_list[groupId] = []
dependency_list[groupId].append(artifact)
for key, value in dependency_list.items():
print(key+": ")
for i in range(len(value)):
print("\t-"+value[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment