Skip to content

Commit 66a9173

Browse files
committed
melting-pot.sh: specify version pins in a file
This change avoids the dreaded "Argument list too long" that happens on Windows with too many -Dx.version=y arguments. One concern I had was whether specifying version overrides as settings.xml properties inside an active-by-default profile would still override the version properties of individual project POMs. But it works. I do not know whether it still works for project POMs with their own profiles that set version properties contingently; in that case, there would be multiple values competing, so it would likely come down to profile evaluation order. Fortunately, that is not common for SciJava-based projects. We also avoid usage of the `\\\\\n` sequence, since it appears to be handled incorrectly by MinGW's /bin/sh.
1 parent ef9a438 commit 66a9173

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

melting-pot.sh

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ do
666666
mismatch=
667667
for dep in $(echo "$deps" | tr ',' '\n')
668668
do
669-
# g:a:p:v:s -> -Dg.a.version=v
669+
# g:a:p:v:s -> <g.a.version>v</g.a.version>
670670
s=${dep##*:}
671671
case "$s" in
672672
test) continue ;; # skip test dependencies
@@ -677,7 +677,7 @@ do
677677
apv=${gapv#*:}
678678
a=${apv%%:*}
679679
v=${apv##*:}
680-
bomV=$(grep -o " -D$g\.$a\.version=[^ ]*" "$dir/build.sh" | sed 's;.*=;;')
680+
bomV=$(grep -o " <$g\.$a\.version>[^>]*" "$dir/version-pins.xml" | sed 's;[^>]*>\([^>]*\)<.*;\1;')
681681
if [ "$bomV" != "${bomV#*-SNAPSHOT*}" ]
682682
then
683683
warn "$1: Snapshot dependency pin detected: $g:$a:$bomV -- forcing a rebuild"
@@ -801,13 +801,9 @@ meltDown() {
801801
# to decide whether to include each component.
802802
generateHelperScripts
803803

804-
# NB: We do *not* include -B here, because we want build.sh to preserve
805-
# colored output if the version of Maven is new enough. We will take care
806-
# elsewhere when parsing it to be flexible about whether colors are present.
807-
local args="-Denforcer.skip"
808-
809804
# Process the dependencies.
810805
info "Processing project dependencies"
806+
local versionProps=""
811807
local dep
812808
for dep in $deps
813809
do
@@ -817,9 +813,9 @@ meltDown() {
817813
local c="$(classifier "$dep")"
818814
test -z "$c" || continue # skip secondary artifacts
819815
local gav="$g:$a:$v"
820-
821816
test -z "$(isChanged "$gav")" &&
822-
args="$args \\\\\n -D$g.$a.version=$v -D$a.version=$v"
817+
versionProps="$versionProps
818+
<$g.$a.version>$v</$g.$a.version> <$a.version>$v</$a.version>"
823819
done
824820

825821
# Override versions of changed GAVs.
@@ -830,16 +826,39 @@ meltDown() {
830826
do
831827
local a="$(artifactId "$gav")"
832828
local v="$(version "$gav")"
833-
args="$args \\\\\n -D$a.version=$v"
829+
versionProps="$versionProps
830+
<$a.version>$v</$a.version>"
834831
done
835832
unset TLS
836833

834+
# Generate version-pins.xml.
835+
info "Generating version-pins.xml configuration"
836+
echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' > version-pins.xml
837+
echo ' xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 https://maven.apache.org/xsd/settings-1.1.0.xsd">' >> version-pins.xml
838+
echo ' <profiles>' >> version-pins.xml
839+
echo ' <profile>' >> version-pins.xml
840+
echo ' <id>version-pins</id>' >> version-pins.xml
841+
echo ' <activation>' >> version-pins.xml
842+
echo ' <activeByDefault>true</activeByDefault>' >> version-pins.xml
843+
echo ' </activation>' >> version-pins.xml
844+
echo ' <properties>' >> version-pins.xml
845+
echo "$versionProps" >> version-pins.xml
846+
echo ' </properties>' >> version-pins.xml
847+
echo ' </profile>' >> version-pins.xml
848+
echo ' </profiles>' >> version-pins.xml
849+
echo '</settings>' >> version-pins.xml
850+
837851
# Generate build script.
838852
info "Generating build.sh script"
839853
echo '#!/bin/sh' > build.sh
840854
echo >> build.sh
855+
echo 'dir=$(cd "$(dirname "$0")" && pwd)' >> build.sh
856+
echo >> build.sh
841857
echo 'mvnPin() {' >> build.sh
842-
echo " mvn $args \\\\\n \$@" >> build.sh
858+
# NB: We do *not* include -B here, because we want build.sh to preserve
859+
# colored output if the version of Maven is new enough. We will take care
860+
# elsewhere when parsing it to be flexible about whether colors are present.
861+
echo ' mvn -s "$dir/version-pins.xml" -Denforcer.skip $@' >> build.sh
843862
echo '}' >> build.sh
844863
echo >> build.sh
845864
echo 'unpackArtifact() {' >> build.sh

0 commit comments

Comments
 (0)