Created
February 4, 2021 16:42
-
-
Save robertorb21/bb6811e5f3878d97d0263ae7d2d82dfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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