Skip to content

Commit e09487d

Browse files
committed
melting-pot: cherry-pick child modules properly
If the SCM link was a multi-module project, let's cherry-pick the relevant child module to include in the melting pot. This makes some assumptions: * The child module will be named the same as its artifactId. * It will be exactly one directory lower than the repository toplevel. Our main use case, TrakEM2, does conform to these expectations, though.
1 parent db4875e commit e09487d

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

melting-pot.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ pruneReactor() {
419419
done
420420
}
421421

422+
# Tests if the given directory contains the appropriate source code.
423+
isProject() {
424+
local a="$(xpath "$1/pom.xml" project artifactId)"
425+
test "$a" = "$(basename "$1")" && echo 1
426+
}
427+
422428
# Generates an aggregator POM for all modules in the current directory.
423429
generatePOM() {
424430
echo '<?xml version="1.0" encoding="UTF-8"?>' > pom.xml
@@ -439,8 +445,15 @@ generatePOM() {
439445
local dir
440446
for dir in */*
441447
do
442-
test -d "$dir" &&
448+
if [ "$(isProject "$dir")" ]
449+
then
443450
echo " <module>$dir</module>" >> pom.xml
451+
else
452+
# Check for a child component of a multi-module project.
453+
local childDir="$dir/$(basename "$dir")"
454+
test "$(isProject "$childDir")" &&
455+
echo " <module>$childDir</module>" >> pom.xml
456+
fi
444457
done
445458
echo ' </modules>' >> pom.xml
446459
echo '</project>' >> pom.xml

tests/melting-pot-multi.t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Test that recursive SCM retrieval works:
1+
Test that recursive SCM retrieval and multi-module projects work:
22

33
$ sh "$TESTDIR/../melting-pot.sh" sc.fiji:TrakEM2_:1.0f -r http://maven.imagej.net/content/groups/public -i 'sc.fiji:TrakEM2_' -v -s -d -f
44
[INFO] sc.fiji:TrakEM2_:1.0f: fetching project source
@@ -17,3 +17,6 @@ Test that recursive SCM retrieval works:
1717
melting-pot/pom.xml
1818
melting-pot/sc.fiji
1919
melting-pot/sc.fiji/TrakEM2_
20+
21+
$ grep '<module>sc.fiji/TrakEM2_/TrakEM2_</module>' melting-pot/pom.xml
22+
\t\t<module>sc.fiji/TrakEM2_/TrakEM2_</module> (esc)

0 commit comments

Comments
 (0)