I want to get snapshot repository url from pom.xml via Python script. Tried following code which works for artifact id but it doesn’t work for url:
import xml.etree as xml
ns = "http://maven.apache.org/POM/4.0.0"
et.register_namespace('', ns)
tree = et.ElementTree()
tree.parse('pom.xml')
pom = tree.parse('pom.xml')
for profile in pom.findall('//{http://maven.apache.org/POM/4.0.0}distributionManagement'):
print(repr(profile))
p = tree.getroot().find("{%s}artifactId" % ns)
Below is the pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<organization>
<name>KP</name>
<url>abc.org/</url>
</organization>
<groupId>org.abc.cloud</groupId>
<artifactId>sample_abc</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>uc1</name>
<description>uc1</description>
distributionManagement>
<snapshotRepository>
<id>local-snapshot</id>
<name>snapShot</name>
<url>
https://pqr/local-snapshot/</url>
</snapshotRepository>
</distributionManagement>
</project>