Skip to content

Commit b4e54be

Browse files
authored
dbeaver/pro#7071 Add checkstyle classpath input for custom checks (#1)
1 parent b2a507c commit b4e54be

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ inputs:
4545
This field will always try to follow Checkstyle releases as close as possible and will use the latest available by default.
4646
If it is not a default preference for your project, please, pin the needed version using this property.
4747
default: ""
48+
checkstyle_classpath:
49+
description: |
50+
Classpath for checkstyle. This is needed when your checkstyle configuration uses custom checks that are not included in the default checkstyle distribution.
51+
You can specify either a single jar file or a directory with multiple jar files. In the latter case, all jar files in the directory will be added to the classpath.
52+
default: ""
4853
properties_file:
4954
description: |
5055
Location of the properties file relative to the root directory. This file serves as a means to resolve repetitive or predefined values within the checkstyle configuration file.

entrypoint.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ if [ -n "${INPUT_PROPERTIES_FILE}" ]; then
1717
OPTIONAL_PROPERTIES_FILE="-p ${INPUT_PROPERTIES_FILE}"
1818
fi
1919

20+
CHECKSTYLE_CLASSPATH="/opt/lib/checkstyle.jar"
21+
if [ -n "${INPUT_CHECKSTYLE_CLASSPATH}" ]; then
22+
CHECKSTYLE_CLASSPATH="${CHECKSTYLE_CLASSPATH}:${INPUT_CHECKSTYLE_CLASSPATH}"
23+
fi
24+
2025
# user wants to use custom Checkstyle version, try to install it
2126
if [ -n "${INPUT_CHECKSTYLE_VERSION}" ]; then
2227
echo '::group::📥 Installing user-defined Checkstyle version ... https://github.com/checkstyle/checkstyle'
@@ -38,7 +43,11 @@ echo '::group:: Running Checkstyle with reviewdog 🐶 ...'
3843
{ echo "Run check with"; java -jar /opt/lib/checkstyle.jar --version; } | sed ':a;N;s/\n/ /;ba'
3944

4045
# shellcheck disable=SC2086
41-
exec java -jar /opt/lib/checkstyle.jar "${INPUT_WORKDIR}" -c "${INPUT_CHECKSTYLE_CONFIG}" ${OPTIONAL_PROPERTIES_FILE} -f xml \
46+
exec \
47+
java \
48+
-cp ${CHECKSTYLE_CLASSPATH} \
49+
com.puppycrawl.tools.checkstyle.Main "${INPUT_WORKDIR}" \
50+
-c "${INPUT_CHECKSTYLE_CONFIG}" ${OPTIONAL_PROPERTIES_FILE} -f xml \
4251
| reviewdog -f=checkstyle \
4352
-name="checkstyle" \
4453
-reporter="${INPUT_REPORTER:-github-pr-check}" \

0 commit comments

Comments
 (0)