File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -278,10 +278,24 @@ pom() {
278278 echo " $pomPath "
279279}
280280
281+ # For the given XML file on disk ($1), gets the value of the
282+ # specified XPath expression of the form "//$2/$3/$4/...".
283+ xpath () {
284+ local xmlFile=" $1 "
285+ shift
286+ local xpath=" /"
287+ while [ $# -gt 0 ]
288+ do
289+ # NB: Ignore namespace issues; see: http://stackoverflow.com/a/8266075
290+ xpath=" $xpath /*[local-name()='$1 ']"
291+ shift
292+ done
293+ xmllint --xpath " $xpath " " $xmlFile " | sed -E ' s/^[^>]*>(.*)<[^<]*$/\1/'
294+ }
295+
281296# Gets the SCM URL for the given GAV.
282297scmURL () {
283- local scmXPath=" //*[local-name()='project']/*[local-name()='scm']/*[local-name()='connection']"
284- xmllint --xpath " $scmXPath " " $( pom " $1 " ) " | sed -E ' s/.*>scm:git:(.*)<.*/\1/'
298+ xpath " $( pom " $1 " ) " project scm connection | sed -E ' s/.*>scm:git:(.*)<.*/\1/'
285299}
286300
287301# Gets the SCM tag for the given GAV.
You can’t perform that action at this time.
0 commit comments