我正在尝试自动执行发布过程。我已经编写了bash脚本,该脚本使用Python3 ElementTree转换XML文件。
我编写了以下脚本,该脚本应在pom.xml中添加以下属性。该工件没有添加到pom2.xml中。
!
对于后续的pom,我想添加一个工件元素。
#!/usr/bin/python
import sys
import xml.etree.ElementTree as ET
def updateAlsPomXml():
tree = ET.parse('pom.xml')
root = tree.getroot()
version = "2.1.3"
for build in root:
if (build.tag == "build"):
for plugins in build:
for plugin in plugins:
for executions in plugin:
for execution in executions:
for configuration in execution:
for artifacts in configuration:
for artifact in artifacts:
art = ET.Element('artifact')
id = ET.SubElement(art, "id")
id.text = 'x.y.z' + version
transitive = ET.SubElement(art, "transitive")
transitive.text = "false"
instructions = ET.SubElement(art, "instructions")
bundleName = ET.SubElement(instructions, "instructions")
bundleName.text = "${pom.name}"
bundleVendor = ET.SubElement(instructions, "instructions")
bundleVendor.text = "${pom.organization.name}"
break
tree.write("pom2.xml")
updateAlsPomXml()