Skip to content

Instantly share code, notes, and snippets.

@robertorb21
Created February 4, 2021 16:42
Show Gist options
  • Save robertorb21/bb6811e5f3878d97d0263ae7d2d82dfb to your computer and use it in GitHub Desktop.
Save robertorb21/bb6811e5f3878d97d0263ae7d2d82dfb to your computer and use it in GitHub Desktop.
#!/bin/bash -e
function get_module() {
local path=$1
while true; do
path=$(dirname $path)
if [ -f "$path/pom.xml" ]; then
echo "$path"
return
elif [[ "./" =~ "$path" ]]; then
return
fi
done
}
modules=()
for file in $(git diff --name-only --cached \*.java); do
module=$(get_module "$file")
if [ "" != "$module" ] \
&& [[ ! " ${modules[@]} " =~ " $module " ]]; then
modules+=("$module")
fi
done
if [ ${#modules[@]} -eq 0 ]; then
exit
fi
modules_arg=$(printf ",%s" "${modules[@]}")
modules_arg=${modules_arg:1}
export MAVEN_OPTS="-client
-XX:+TieredCompilation
-XX:TieredStopAtLevel=1
-Xverify:none"
mvn -q -pl "$modules_arg" checkstyle:check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment