POM_XPATH_SET(7)

πŸ’– POM_XPATH_SET(7) πŸ’–

Java Packages Tools Β· the pom_xpath_set glow-up

okay bestie, pull up a chair because we're about to talk about the icon that is pom_xpath_set πŸŽ€


✨ NAME ✨

pom_xpath_set β€” set contents of XML node from XML file πŸ’…


✨ SYNOPSIS ✨

%pom_xpath_set XPath new-contents [XML-file-location]

that's it. three little things. so simple. so powerful. periodt 🫢


✨ DESCRIPTION ✨

so what does this macro actually do, you ask? 🌸

It patches a specified POM file, replacing the contents of all XML nodes described by the XPath expression with the new text content you handed it. And the range?? literally immaculate β€” it works on both elements and attributes. no cap. πŸ’–

XPath is an expression describing a set of XML nodes to be removed from the POM file. It has to be a properly formated XPath 1.0 expression, exactly as described over at http://www.w3.org/TR/xpath/ β€” so like, don't freestyle it, bestie, the spec is the spec πŸ“œ

now here's the part that gets people every single time, and I need you to hear me πŸ™ˆ

Maven POM files use a specific XML namespace, http://maven.apache.org/POM/4.0.0, as default. That namespace has to be explicitly specified in your XPath expressions by prefixing all node names with pom β€” so like, pom:modelVersion, not just modelVersion. the way that pom: prefix is non-negotiable… iconic of it honestly πŸ‘‘

and it's not just Maven, bestie. Many other XML formats also use namespaces which you have to explicitly specify. This script will use the namespace prefix names from the xmlns declarations in the document's root element. So if the document begins with <root xmlns:my="myurl.com"> you would select the root node with the XPath expression /my:root. See how the prefix just ✨matches✨? obsessed.

And if the document specifies a default namespace (eg xmlns="myurl.com") β€” listen β€” you use the prefix named default to acces elements in that namespace. yes, literally the word default. it's giving secret handshake 🀝

lastly, XML location can be either a full path to the XML, or a path to the directory containing pom.xml or ivy.xml. If XML location is not given, then pom.xml or ivy.xml from the current working directory is used. And when both pom.xml and ivy.xml are present?? pom.xml is processed β€” it wins, sorry ivy πŸ“

oh and you can specify more file locations. go off, specify as many as your heart desires πŸ’œ

⚠️ real talk: that XPath expression has to be valid XPath 1.0. if it's not, that's not a vibe, that's a bug report.

✨ AUTHOR ✨

Written by Mikolaj Izdebski. king behavior, fr fr πŸ‘‘


✨ REPORTING BUGS ✨

Found a bug? 😭 don't suffer in silence, bestie. Bugs should be reported through the Java Packages Tools issue tracker at Github:

https://github.com/fedora-java/javapackages/issues


✨ SEE ALSO ✨

the whole friend group 🫢 go read these too:


and that's the whole page, bestie ✨ this one's from JAVAPACKAGES, dated 2025-09-19, and it's the POM_XPATH_SET(7) manual. go set some nodes. you got this πŸ’–πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from