Linux repositories inspector




Macros and scripts for Java packaging support


Non-essential macros and scripts for Java packaging support


pom_xpath_inject - inject code into XML file


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


This macro patches specified XML file appending given code as children of all XML nodes described by the XPath expression.
XPath is an expression describing a set of XML nodes in the XML file to which child code is to be appended. It must be a properly formated XPath 1.0 expression, as described in \m[blue]\m[].
Maven POM files use specific XML namespace as default. This namespace needs to be explicitly specified in XPath expressions by prefixing all node names with pom: (i.e. pom:modelVersion).
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\(cqs root element. So if the document begins with <root xmlns:my=""> you would select the root node with XPath expression /my:root. If the document specifies a default namespace (e.g. xmlns="") use the prefix named default to acces elements in that namespace.
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 current working directory is used. When both pom.xml and ivy.xml are present, pom.xml is processed. You can specify more file locations.


%pom_xpath_inject pom:project "<packaging>war</packaging>" - this call sets packaging of POM in current working directory to war.
%pom_xpath inject configurations <conf name="test"/> - this adds a new configuration to the Ivy file in current working directory.


Written by Mikolaj Izdebski.


Bugs should be reported through Java Packages Tools issue tracker at Github: \m[blue]\m[].
⇧ Top