vitess.io/vitess@v0.16.2/misc/git/hooks/checkstyle (about)

     1  #!/bin/bash
     2  
     3  set -e
     4  
     5  function get_module() {
     6    local path=$1;
     7    while true; do
     8      path=$(dirname $path);
     9      if [ -f "$path/pom.xml" ]; then
    10        echo "$path";
    11        return;
    12      elif [[ "./" =~ "$path" ]]; then
    13        return;
    14      fi
    15    done
    16  }
    17  
    18  cd java;
    19  
    20  modules=();
    21  
    22  for file in $(git diff --relative --name-only --cached \*.java); do
    23    module=$(get_module "$file");
    24    if [ "" != "$module" ] \
    25        && [[ ! " ${modules[@]} " =~ " $module " ]]; then
    26      modules+=("$module");
    27    fi
    28  done;
    29  
    30  if [ ${#modules[@]} -eq 0 ]; then
    31    exit;
    32  fi
    33  
    34  modules_arg=$(printf ",%s" "${modules[@]}");
    35  modules_arg=${modules_arg:1};
    36  
    37  export MAVEN_OPTS="-client
    38    -XX:+TieredCompilation
    39    -XX:TieredStopAtLevel=1
    40    -Xverify:none";
    41  
    42  mvn -q -pl "$modules_arg" checkstyle:check;
    43  
    44  cd -;