hoomb
hoomb

Reputation: 686

find a specific groupId from a maven pom.xml using xmstarlet

I'm trying to find a specific groupId and artifactId from a Maven POM.XML using xmlstarlet without success. This is the command that I'm using:

xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t \
     -m "/pom:project/pom:dependencyManagement/pom:dependencies/pom:dependency[.//pom:groupId=com.mygroup.xxx]" \ 
     -v '.' pom.xml 

any Help is appreciated.

EDIT: Thank to npostavs, for other people who have the same question, It is also possible to combine more expressions and filter the result based on more elements:

  xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t -m "/pom:project/pom:dependencyManagement/pom:dependencies/dependency[.//pom:groupId='com.mygroup.xxx'][.//pom:artifactId='myartifact-xxx']" -v '.' pom.xml

Upvotes: 5

Views: 1487

Answers (1)

npostavs
npostavs

Reputation: 5027

pom:groupId=com.mygroup.xxx

You need quotes around string literals: pom:groupId='com.mygroup.xxx', otherwise it looks for XML elements named com.mygroup.xxx.

Upvotes: 5

Related Questions