|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +PASS=1 |
| 4 | +REPO_ROOT=$(git rev-parse --show-toplevel) |
| 5 | +if [[ -z $REPO_ROOT ]]; then |
| 6 | + echo "Could not detect git repo root" |
| 7 | + exit 2 |
| 8 | +fi |
| 9 | + |
| 10 | +repeatable=$(grep -r --include \*.java java.lang.annotation.Repeatable "$REPO_ROOT") |
| 11 | +getannotationsbytype=$(grep -r --include \*.java AnnotatedElement.getAnnotationsByType "$REPO_ROOT") |
| 12 | +stream=$(grep -r --include \*.java java.util.stream "$REPO_ROOT") |
| 13 | +stream2=$(grep -r --include \*.java Arrays.stream "$REPO_ROOT") |
| 14 | +functionalinterface=$(grep -r --include \*.java java.lang.FunctionalInterface "$REPO_ROOT") |
| 15 | +reflectisdefault=$(grep -r --include \*.java java.lang.reflect.isDefault "$REPO_ROOT") |
| 16 | +function=$(grep -r --include \*.java java.util.function "$REPO_ROOT") |
| 17 | + |
| 18 | +if [[ ! -z $repeatable ]]; then |
| 19 | + echo -e "Error: Usage of java.lang.annotation.Repeatable found:\n$repeatable" |
| 20 | + PASS=0 |
| 21 | +fi |
| 22 | +if [[ ! -z $getannotationsbytype ]]; then |
| 23 | + echo -e "Error: Usage of AnnotatedElement.getAnnotationsByType found:\n$getannotationsbytype" |
| 24 | + PASS=0 |
| 25 | +fi |
| 26 | +if [[ ! -z $stream ]]; then |
| 27 | + echo -e "Error: Usage of java.util.stream found:\n$stream" |
| 28 | + PASS=0 |
| 29 | +fi |
| 30 | +if [[ ! -z $stream2 ]]; then |
| 31 | + echo -e "Error: Usage of Arrays.stream found:\n$stream2" |
| 32 | + PASS=0 |
| 33 | +fi |
| 34 | +if [[ ! -z $functionalinterface ]]; then |
| 35 | + echo -e "Error: Usage of java.lang.FunctionalInterface found:\n$functionalinterface" |
| 36 | + PASS=0 |
| 37 | +fi |
| 38 | +if [[ ! -z $reflectisdefault ]]; then |
| 39 | + echo -e "Error: Usage of java.lang.reflect.isDefault found:\n$reflectisdefault" |
| 40 | + PASS=0 |
| 41 | +fi |
| 42 | +if [[ ! -z $function ]]; then |
| 43 | + echo -e "Error: Usage of java.util.function found:\n$function" |
| 44 | + PASS=0 |
| 45 | +fi |
| 46 | + |
| 47 | +if (( $PASS == 0 )); then |
| 48 | + echo "" |
| 49 | + echo "Unfortunately the APIs listed above are not supported by Android" |
| 50 | + echo "below API version 24, so they should not be used in SaltyRTC." |
| 51 | + exit 1 |
| 52 | +else |
| 53 | + echo "No forbidden APIs found" |
| 54 | + exit 0 |
| 55 | +fi |
0 commit comments