8000 mega-melt: update to realign with melting-pot.sh · scijava/pom-scijava@8382585 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8382585

Browse files
committed
mega-melt: update to realign with melting-pot.sh
The melting-pot.sh script in scijava-scripts now places version property pins into a dedicated version-pins.xml file in Maven settings.xml style, rather than passing the versions directly to mvn via -D arguments. So we need to adjust the post-generation 8000 hacks here accordingly. And ensure that sed commands really do something. Whether or not sed changes any lines, it returns success. But we want to be sure that the command actually made a change.
1 parent 6a0161f commit 8382585

File tree

1 file changed

+42
-23
lines changed

1 file changed

+42
-23
lines changed

tests/run.sh

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
die () { echo "$*" >&2; exit 1; }
88

9+
changed () { ! diff $@ >/dev/null; }
10+
911
sectionStart() {
1012
startTime=$(date +%s)
1113
echo
@@ -117,6 +119,7 @@ test "$(grep -F "[ERROR]" "$meltingPotLog" | grep -v "using default branch")" &&
117119
die 'Melting pot generation failed!'
118120

119121
buildScript="$meltingPotDir/build.sh"
122+
versionPins="$meltingPotDir/version-pins.xml"
120123

121124
echo
122125
echo 'Hacking in any changed components...'
@@ -196,7 +199,7 @@ do
196199
if [ -f gav ]
197200
then
198201
mv gav gav.prehacks
199-
sed -E "s;:[^:]*$;:999;" gav.prehacks > gav || {
202+
sed -E "s;:[^:]*$;:999;" gav.prehacks > gav && changed gav.prehacks gav || {
200203
touch "$failFile"
201204
die "$g:$a: failed to adjust gav version"
202205
}
@@ -210,17 +213,20 @@ do
210213
}
211214
printf .
212215

213-
# Adjust component version to 999 in melting pot's build.sh.
216+
# Adjust component version to 999 in melting pot's version-pins.xml.
214217
cd "$meltingPotDir"
215-
test -f "$buildScript.prehacks" || cp "$buildScript" "$buildScript.prehacks" || {
218+
test -f "$versionPins.prehacks" || cp "$versionPins" "$versionPins.prehacks" || {
216219
touch "$failFile"
217-
die "$g:$a: failed to back up $buildScript"
220+
die "$g:$a: failed to back up $versionPins"
218221
}
219222
printf .
220-
mv -f "$buildScript" "$buildScript.tmp" &&
221-
sed -E "s;(-D($g\\.)?$a\\.version)=[^ ]*;\1=999;g" "$buildScript.tmp" > "$buildScript" || {
223+
echo "$a" | grep -q '^[0-9]' && aa="_$a" || aa="$a"
224+
mv -f "$versionPins" "$versionPins.tmp" &&
225+
sed -E "s;<\($g\\.$a\|$aa\)\\.version>[^<]*;<\1.version>999;g" "$versionPins.tmp" > "$versionPins" &&
226+
changed "$versionPins.tmp" "$versionPins" ||
227+
{
222228
touch "$failFile"
223-
die "$g:$a: failed to adjust component version in $buildScript"
229+
die "$g:$a: failed to adjust component version in $versionPins"
224230
}
225231
printf .
226232

@@ -235,36 +241,48 @@ do
235241
}
236242
printf ".\n"
237243
done
238-
rm -f "$buildScript.tmp" "$meltScript.tmp"
244+
rm -f "$versionPins.tmp" "$meltScript.tmp"
239245
test ! -f "$failFile" ||
240246
die "Failed to hack in changed components!"
241247

242-
sectionStart 'Adjusting the melting pot: build.sh script'
248+
sectionStart 'Adjusting the melting pot: version-pins.xml configuration'
243249

244-
cp "$buildScript" "$buildScript.original" &&
250+
cp "$versionPins" "$versionPins.original" &&
245251

246252
# HACK: Remove known-duplicate short version properties, keeping
247253
# the short version declaration only for the more common groupId.
248254
# E.g.: org.antlr:antlr is preferred over antlr:antlr, so we set
249255
# antlr.version to match org.antlr:antlr, not antlr:antlr.
250-
mv -f "$buildScript" "$buildScript.tmp" &&
251-
sed -E 's;(-D('"$shortVersionClashes"').version=[^ ]*) -D[^ ]*;\1;' "$buildScript.tmp" > "$buildScript" &&
252-
253-
# HACK: Add leading underscore to version properties that start with a digit.
254-
mv -f "$buildScript" "$buildScript.tmp" &&
255-
sed -E 's; -D([0-9][^ ]*);& -D_\1;' "$buildScript.tmp" > "$buildScript" &&
256+
mv -f "$versionPins" "$versionPins.tmp" &&
257+
sed -E 's;(<('"$shortVersionClashes"')\.version>[^ ]*) <[^ ]*;\1;' "$versionPins.tmp" > "$versionPins" &&
258+
changed "$versionPins.tmp" "$versionPins" ||
259+
die 'Error adjusting melting pot version pins! [1]'
256260

257261
# HACK: Add non-standard version properties used prior to
258262
# pom-scijava 32.0.0-beta-1; see d0bf752070d96a2613c42e4e1ab86ebdd07c29ee.
259-
mv -f "$buildScript" "$buildScript.tmp" &&
260-
sed -E 's; -Dsc.fiji.3D_Blob_Segmentation\.version=([^ ]*);& -DFiji_3D_Blob_Segmentation.version=\1;' "$buildScript.tmp" > "$buildScript" &&
261-
mv -f "$buildScript" "$buildScript.tmp" &&
262-
sed -E 's; -Dsc.fiji.(3D_Objects_Counter|3D_Viewer)\.version=([^ ]*);& -DImageJ_\1.version=\2;' "$buildScript.tmp" > "$buildScript" &&
263+
mv -f "$versionPins" "$versionPins.tmp" &&
264+
sed -E 's; <sc.fiji.3D_Blob_Segmentation\.version>([^<]*)</sc.fiji.3D_Blob_Segmentation.version>;& <Fiji_3D_Blob_Segmentation.version>\1</Fiji_3D_Blob_Segmentation.version>;' "$versionPins.tmp" > "$versionPins" &&
265+
changed "$versionPins.tmp" "$versionPins" &&
266+
mv -f "$versionPins" "$versionPins.tmp" &&
267+
sed -E 's; <sc.fiji.(3D_Objects_Counter|3D_Viewer)\.version>([^<]*)</sc.fiji.(3D_Objects_Counter|3D_Viewer).version>;& <ImageJ_\1.version>\2</ImageJ_\1.version>;' "$versionPins.tmp" > "$versionPins" &&
268+
changed "$versionPins.tmp" "$versionPins" ||
269+
die 'Error adjusting melting pot version pins! [2]'
263270

264271
# HACK: Add non-standard net.imagej:ij version property used prior to
265272
# pom-scijava 28.0.0; see 7d2cc442b107b3ac2dcb799d282f2c0b5822649d.
266-
mv -f "$buildScript" "$buildScript.tmp" &&
267-
sed -E 's; -Dij\.version=([^ ]*);& -Dimagej1.version=\1;' "$buildScript.tmp" > "$buildScript" &&
273+
mv -f "$versionPins" "$versionPins.tmp" &&
274+
sed -E 's; <ij\.version>([^<]*)</ij\.version>;& <imagej1.version>\1</imagej1.version>;' "$versionPins.tmp" > "$versionPins" &&
275+
changed "$versionPins.tmp" "$versionPins" ||
276+
die 'Error adjusting melting pot version pins! [3]'
277+
278+
rm "$versionPins.tmp" ||
279+
die 'Error adjusting melting pot version pins! [4]'
280+
281+
sectionEnd # Adjusting the melting pot: version-pins.xml configuration
282+
283+
sectionStart 'Adjusting the melting pot: build.sh script'
284+
285+
cp "$buildScript" "$buildScript.original" &&
268286

269287
# HACK: Add explicit kotlin.version to match our pom-scijava-base.
270288
# Otherwise, components built on older pom-scijava-base will have
@@ -294,7 +312,8 @@ enforcerVersion=$(
294312
-Dexec.args='${maven-enforcer-plugin.version}' --non-recursive validate exec:exec 2>&1 |
295313
head -n1 | sed 's;\(.\[[0-9]m\)*;;') &&
296314
mv -f "$buildScript" "$buildScript.tmp" &&
297-
sed -E "s;mvn -Denforcer.skip;& -Dmaven-enforcer-plugin.version=$enforcerVersion -Dkotlin.version=$kotlinVersion;" "$buildScript.tmp" > "$buildScript" &&
315+
sed -E "s;mvn .*-Denforcer.skip;& -Dmaven-enforcer-plugin.version=$enforcerVersion -Dkotlin.version=$kotlinVersion;" "$buildScript.tmp" > "$buildScript" &&
316+
changed "$buildScript.tmp" "$buildScript" &&
298317

299318
chmod +x "$buildScript" &&
300319
rm "$buildScript.tmp" ||

0 commit comments

Comments
 (0)
0