Skip to content

Commit

Permalink
build: add check-forbidden-classes.sh 🚫
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Apr 2, 2024
1 parent 0903fc3 commit f8a55c8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ jobs:
cache: maven
- run: ./mvnw -V --no-transfer-progress clean package
if: matrix.java != 17
- run: ./mvnw -V --no-transfer-progress clean package spotbugs:check git-commit-id:validateRevision -DperformRelease
if: matrix.java == 17
- run: |
./mvnw -V --no-transfer-progress clean package spotbugs:check git-commit-id:validateRevision -DperformRelease
scripts/check-forbidden-classes.sh
if: matrix.java == 17 && runner.os != 'Linux'
# https://github.com/marketplace/actions/codecov
- uses: codecov/codecov-action@v4
env:
Expand Down
21 changes: 21 additions & 0 deletions scripts/check-forbidden-classes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -eEuo pipefail

# cd to project root dir
cd "${0%/*}"/..

readonly forbidden_classes=(
javax.annotation.Nullable
javax.annotation.Nonnull
org.jetbrains.annotations.Nullable
org.jetbrains.annotations.NotNull
)

grep_options=()
[[ "${GITHUB_ACTIONS:-}" = true || -t 1 ]] && grep_options=(--color=always)
readonly grep_options=(-F ${grep_options[@]:+"${grep_options[@]}"} -n -C2 -r src/)

! grep "$(printf "%s\n" "${forbidden_classes[@]}")" "${grep_options[@]}" || {
printf '\n\e[1;31m%s\e[0m\n' "Forbidden classes found, remove them."
exit 1
}

0 comments on commit f8a55c8

Please sign in to comment.