1#!/bin/bash 2 3set -e 4 5GENERATION_DIR=$(dirname -- "$0"); 6 7# Find all Maven modules (a directory that contains pom.xml) 8find . -mindepth 2 -maxdepth 2 -name pom.xml |sort --dictionary-order | xargs dirname \ 9 |sed -e 's|./||' | xargs -I '{}' echo " <module>{}</module>" > /tmp/repo-modules.txt 10 11perl -0pe 's/<modules>.*<\/modules>/<modules>\n <\/modules>/s' ${GENERATION_DIR}/../pom.xml > ${GENERATION_DIR}/parent.pom.xml 12awk -v MODULES="`awk -v ORS='\\\\n' '1' /tmp/repo-modules.txt`" '1;/<modules>/{print MODULES}' ${GENERATION_DIR}/parent.pom.xml > pom.xml 13rm ${GENERATION_DIR}/parent.pom.xml