Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save frode-carlsen/e4d6f4218994e3797652e57622c88ab5 to your computer and use it in GitHub Desktop.
Save frode-carlsen/e4d6f4218994e3797652e57622c88ab5 to your computer and use it in GitHub Desktop.
# Bash function to only build modules (and dependent modules) in a multi-module reactor which have been touched since current branch was forked.
function mvnd {
# NB! ignores changes in pom modules
# NB! checks only diffs branch from local master
find . -maxdepth 4 -name pom.xml | xargs -I{} grep -iL -F "<packaging>pom</packaging>" {} | xargs dirname |grep -v target | sed -e 's/^.[/]*//g' | grep . > /tmp/mvn-modules.txt && git diff --name-only master | grep -o -F -f /tmp/mvn-modules.txt | xargs | tr ' ' ',' | xargs -I{} mvn $@ -pl {}
}
function mvndu {
# NB! diffs from upstream head (can be used on master branch)
find . -maxdepth 4 -name pom.xml | xargs -I{} grep -iL -F "<packaging>pom</packaging>" {} | xargs dirname |grep -v target | sed -e 's/^.[/]*//g' | grep . > /tmp/mvn-modules.txt && git diff --name-only @{u}...HEAD | grep -o -F -f /tmp/mvn-modules.txt | xargs | tr ' ' ',' | xargs -I{} mvn $@ -U -pl {} -amd -pl \!build/ear,\!build/war
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment