python自动判断Maven依赖
python自动判断Maven依赖
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
""" naee 自动判断Maven依赖 by 陈思奇 time 2019.9.9 methods 填写好下方的项目绝路路径和groupId运行后复制运行结果粘贴到excel即可 """ import os.path from xml.dom.minidom import parse
ProjectPath = "D:\project\java\IntelliJ\cathayfuture" yourGroupId = "com.baokang"
excelPast = '服务名\t依赖\n' rootDir = os.path.abspath(ProjectPath) for parent, dirnames, filenames in os.walk(rootDir): for filename in filenames: if "pom.xml" == filename: pathfile = os.path.join(parent, filename) DOMTree = parse(pathfile) project = DOMTree.documentElement dependencies = project.getElementsByTagName('dependencies') if dependencies.length == 0: continue dependencyList = dependencies[0].getElementsByTagName('dependency') dependencyStr = '' for dependency in dependencyList: groupId = dependency.getElementsByTagName('groupId')[0] if groupId.firstChild.data == yourGroupId: dependencyStr += \ dependency.getElementsByTagName('artifactId')[0].firstChild.data + '\n' if dependencyStr != '': dependencyStr = dependencyStr[:len(dependencyStr) - 1] excelPast += parent[parent.rfind("\\") + 1:] + "\t\"" + dependencyStr + "\"\n" print(excelPast)
|
此为博主副博客,留言请去主博客,转载请注明出处:https://www.baby7blog.com/myBlog/41.html