POM_XPATH_REPLACE(7)

πŸ’– POM_XPATH_REPLACE πŸ’–

okay bestie, welcome to pom_xpath_replace from the Java Packages Tools manual, section 7. yes the manual name is literally screaming at you in all caps at the top and honestly? it's giving main character energy. sit down, grab a boba, we're swapping XML nodes out of your POM like it's nothing. 🫢


✨ NAME ✨

pom_xpath_replace β€” replace XML node from XML file with given code

like. the whole vibe. find the node, yeet the node, drop new code in its place. periodt. πŸ’…


🌸 SYNOPSIS 🌸

%pom_xpath_replace XPath XML-code [XML-file-location]...

that's it, that's the whole thing. XPath to say which node, XML code to say what goes there instead, and then as many file locations as your little heart desires. 🌈


πŸŽ€ OPTIONS πŸŽ€

  • -r β€” recursive mode, bestie!! the node you picked also gets replaced in all enabled submodules of the POM file(s) you handed over. and listen: if the file isn't a Maven POM, this option literally does nothing. no effect. zero. zip. it's giving "I showed up but there was no party". πŸ’€
  • -f β€” do not throw an error when one of the files you specified doesn't contain the given node. so like, chill mode. no drama, no tantrum, just vibes. 😌

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie. this macro patches the POM file you point it at by removing every XML node that matches your XPath expression and then injecting the given XML code right there in their place. in and out. slay. ✨

XPath is the expression that describes the set of XML nodes getting removed from the POM file. it must be a properly formatted XPath 1.0 expression, exactly as described in http://www.w3.org/TR/xpath/. no freestyling. no vibes-based syntax. the spec said what it said. πŸ‘‘

Maven POM files use the specific XML namespace http://maven.apache.org/POM/4.0.0 as their default. and here's the catch β€” you have to explicitly specify that namespace in your XPath expressions by prefixing every single node name with pom. so like, pom:modelVersion, not just modelVersion. iykyk. 🧚

and it's not just POMs, bestie. many other XML formats use namespaces too, and you have to explicitly specify those as well. the good news: this script pulls the namespace prefix names straight from the xmlns declarations in the document's root element. so if your document starts with

<root xmlns:my="myurl.com">

then you'd select that root node with the XPath expression /my:root. clean. and if the document declares a default namespace like xmlns="myurl.com", you use the prefix named default to access elements in that namespace. yes, literally the word default. that's the whole trick. 🌟

now, where does it look for your file? XML location can be either:

  • a full path to the XML, or
  • a path to the directory containing pom.xml or ivy.xml.

if you don't give an XML location at all, then pom.xml or ivy.xml from the current working directory gets used. and when both pom.xml and ivy.xml are sitting there being cute? pom.xml wins, it's the one that gets processed. also β€” you can specify more file locations. as many as you want. go off. πŸŽ‰


πŸ‘‘ AUTHOR πŸ‘‘

Written by Mikolaj Izdebski. an icon. we thank him for his service. 🫢


πŸ™ˆ 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

go tell them. they wanna know. fr fr. πŸ’Œ


⭐ SEE ALSO ⭐

your reading list, and every single one of them is a banger:


okay that's the whole page, no cap. this one came from the JAVAPACKAGES crew and it's dated 2025-09-19 β€” so if you're reading this way later, hi from the past, hope your builds are green. πŸ’–βœ¨ bye bestie, go replace some nodes! πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from