diff --git a/build.bat b/build.bat index d050956a4d..316a215103 100644 --- a/build.bat +++ b/build.bat @@ -25,7 +25,7 @@ @REM @echo off -setlocal enabledelayedexpansion +setlocal set "TARGET=useage" set "DEBUG=false" @@ -118,16 +118,21 @@ if "%TARGET%"=="clean" ( ) else if "%TARGET%"=="dependency-security-check" ( set "CMD=%BASE_CMD% dependency-check:check" ) else if "%TARGET%"=="format-poms" ( + setlocal enabledelayedexpansion set "SAXON=%USERPROFILE%\.m2\repository\net\sf\saxon\Saxon-HE\9.9.1-8\Saxon-HE-9.9.1-8.jar" - for /r %%POM in (pom.xml) do ( - echo | set /p dummyName="Formatting %%POM ..." - java -jar "%SAXON%" -s:%%POM -xsl:format-pom.xslt -o:%%POM - echo OK + for /r %%P in (pom.xml) do ( + if exist "%%P" ( + set "POM=%%P" + echo | set /p dummyName="Formatting !POM! ..." + java -jar "!SAXON!" -s:!POM! -xsl:format-pom.xslt -o:!POM! + echo OK - echo | set /p dummyName="Checking for duplicate license entries in %%POM ... " - java -cp "%SAXON%" net.sf.saxon.Query -q:check-pom-license-uniqueness.xq pom-file-uri=file:%%POM - echo OK + echo | set /p dummyName="Checking for duplicate license entries in !POM! ... " + java -cp "!SAXON!" net.sf.saxon.Query -q:check-pom-license-uniqueness.xq pom-file-path=!POM! + echo OK + ) ) + endlocal goto end ) else ( echo Invalid target: %TARGET% diff --git a/build.sh b/build.sh index 37673a114d..c278cec94f 100755 --- a/build.sh +++ b/build.sh @@ -182,7 +182,7 @@ if [ "${TARGET}" == "format-poms" ]; then echo "OK" echo -n "Checking for duplicate license entries in ${pom} ... " - CMD="java -cp ${SAXON} net.sf.saxon.Query -q:check-pom-license-uniqueness.xq pom-file-uri=file:${pom}" + CMD="java -cp ${SAXON} net.sf.saxon.Query -q:check-pom-license-uniqueness.xq pom-file-path=${pom}" $CMD echo "OK" diff --git a/check-pom-license-uniqueness.xq b/check-pom-license-uniqueness.xq index 6407294d9d..8721bcb5d5 100644 --- a/check-pom-license-uniqueness.xq +++ b/check-pom-license-uniqueness.xq @@ -31,9 +31,18 @@ declare namespace pom = "http://maven.apache.org/POM/4.0.0"; declare option output:omit-xml-declaration "yes"; -(: Must be set externally with the URI to the pom.xml file :) -declare variable $pom-file-uri as xs:string external; +(: Must be set externally with the file-system path to the pom.xml file :) +declare variable $pom-file-path as xs:string external; +declare %private function local:path-to-uri($path as xs:string) as xs:string { + if (starts-with($path, "/")) + then + "file://" || $path + else + "file:///" || replace($path, "\\", "/") +}; + +let $pom-file-uri := local:path-to-uri($pom-file-path) let $pom := doc($pom-file-uri) return (