Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ if /I "%~1"=="--debug" (
set "TARGET=dependency-check"
) else if /I "%~1"=="dependency-security-check" (
set "TARGET=dependency-security-check"
) else if /I "%~1"=="format-poms" (
set "TARGET=format-poms"
)
shift
goto parse_args
Expand Down Expand Up @@ -115,6 +117,18 @@ if "%TARGET%"=="clean" (
set "CMD=%BASE_CMD% dependency:analyze"
) else if "%TARGET%"=="dependency-security-check" (
set "CMD=%BASE_CMD% dependency-check:check"
) else if "%TARGET%"=="format-poms" (
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

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
)
goto end
) else (
echo Invalid target: %TARGET%
goto show_useage
Expand Down
22 changes: 21 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ do
key="$1"

case $key in
clean|quick|quick-archives|quick-docker|quick-archives-docker|quick-install|test|site|license-check|license-format|dependency-check|dependency-security-check)
clean|quick|quick-archives|quick-docker|quick-archives-docker|quick-install|test|site|license-check|license-format|dependency-check|dependency-security-check|format-poms)
TARGET="$1"
shift
;;
Expand Down Expand Up @@ -75,6 +75,7 @@ function print-useage() {
echo -e "\tlicence-format - Adds the correct license header to any source files that are missing it"
echo -e "\tdependency-check - Checks that all modules have correctly declared their dependencies"
echo -e "\tdependency-security-check - Checks that all dependencies have no unexpected CVE security issues"
echo -e "\tformat-poms - Format the pom.xml files"
echo -e "\tclean - Remove all built artifacts"
echo -e "\n--offline - attempts to run the Maven build in offline mode"
}
Expand Down Expand Up @@ -170,5 +171,24 @@ if [ "${TARGET}" == "dependency-security-check" ]; then
exit 0;
fi

if [ "${TARGET}" == "format-poms" ]; then
SAXON="${HOME}/.m2/repository/net/sf/saxon/Saxon-HE/9.9.1-8/Saxon-HE-9.9.1-8.jar"
POMS="$(find . -name pom.xml)"
for pom in $POMS; do

echo -n "Formatting ${pom} ... "
CMD="java -jar ${SAXON} -s:${pom} -xsl:format-pom.xslt -o:${pom}"
$CMD
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
echo "OK"

done
exit 0;
fi

print-useage
exit 0;
79 changes: 79 additions & 0 deletions check-pom-license-uniqueness.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
(:
: Elemental
: Copyright (C) 2024, Evolved Binary Ltd
:
: admin@evolvedbinary.com
: https://www.evolvedbinary.com | https://www.elemental.xyz
:
: This library is free software; you can redistribute it and/or
: modify it under the terms of the GNU Lesser General Public
: License as published by the Free Software Foundation; version 2.1.
:
: This library is distributed in the hope that it will be useful,
: but WITHOUT ANY WARRANTY; without even the implied warranty of
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
: Lesser General Public License for more details.
:
: You should have received a copy of the GNU Lesser General Public
: License along with this library; if not, write to the Free Software
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
:)
xquery version "3.1";

(:~
: Checks within the <excludes> and <includes> of each <licenseSet> with a pom.xml
: file to make sure there are no duplicate entries.
:)

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
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;

let $pom := doc($pom-file-uri)
return
(

let $includes-elements := $pom//pom:includes
for $includes-element in $includes-elements
let $total-includes := count($includes-element/pom:include/string(.))
let $distinct-includes := count(distinct-values($includes-element/pom:include/string(.)))
return
if ($total-includes ne $distinct-includes)
then
let $duplicates :=
distinct-values(
for $include in $includes-element/pom:include/string(.)
where count($includes-element/pom:include[. eq $include]) gt 1
return $include
)
return
error(xs:QName("duplicate-include"), "There are duplicate 'include' license entries within a 'licenseSet' in: " || $pom-file-uri || " at: " || path($includes-element) || " duplicates: " || string-join($duplicates, ", "))
else
()

,

let $excludes-elements := $pom//pom:excludes[parent::pom:licenseSet]
for $excludes-element in $excludes-elements
let $total-excludes := count($excludes-element/pom:exclude/string(.))
let $distinct-excludes := count(distinct-values($excludes-element/pom:exclude/string(.)))
return
if ($total-excludes ne $distinct-excludes)
then
let $duplicates :=
distinct-values(
for $exclude in $excludes-element/pom:exclude/string(.)
where count($excludes-element/pom:exclude[. eq $exclude]) gt 1
return $exclude
)
return
error(xs:QName("duplicate-exclude"), "There are duplicate 'exclude' license entries within a 'licenseSet' in: " || $pom-file-uri || " at: " || path($excludes-element) || " duplicates: " || string-join($duplicates, ", "))
else
()

)
4 changes: 2 additions & 2 deletions elemental-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
</dependency>
</dependencies>
<configuration>
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory" />
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
<forkCount>${surefire.forkCount}</forkCount>
<reuseForks>${surefire.reuseForks}</reuseForks>
<argLine>@{jacocoArgLine} --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED -Dfile.encoding=${project.build.sourceEncoding}</argLine>
Expand Down Expand Up @@ -705,4 +705,4 @@
</repository>
</distributionManagement>

</project>
</project>
12 changes: 6 additions & 6 deletions exist-ant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@
</multi>
<includes>
<include>pom.xml</include>
<include>src/test/resources/log4j2.xml</include>
<include>src/test/resources-filtered/conf.xml</include>
<include>src/test/resources/log4j2.xml</include>
</includes>
</licenseSet>

Expand All @@ -183,14 +183,14 @@
-->
<header>${project.parent.relativePath}/../exist-parent/existdb-LGPL-21-license.template.txt</header>
<excludes>
<exclude>**.txt</exclude>
<exclude>**.md</exclude>
<exclude>**LICENSE</exclude>
<exclude>**.txt</exclude>
<exclude>**.xar</exclude>
<exclude>xquery-license-style.xml</exclude>
<exclude>**LICENSE</exclude>
<exclude>pom.xml</exclude>
<exclude>src/test/resources/log4j2.xml</exclude>
<exclude>xquery-license-style.xml</exclude>
<exclude>src/test/resources-filtered/conf.xml</exclude>
<exclude>src/test/resources/log4j2.xml</exclude>
</excludes>
</licenseSet>
</licenseSets>
Expand All @@ -200,4 +200,4 @@

</build>

</project>
</project>
2 changes: 1 addition & 1 deletion exist-core-jcstress/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@
</plugins>
</build>

</project>
</project>
2 changes: 1 addition & 1 deletion exist-core-jmh/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@
</plugins>
</build>

</project>
</project>
Loading
Loading