diff --git a/action.yml b/action.yml index ff30972..c91bc26 100644 --- a/action.yml +++ b/action.yml @@ -45,6 +45,11 @@ inputs: This field will always try to follow Checkstyle releases as close as possible and will use the latest available by default. If it is not a default preference for your project, please, pin the needed version using this property. default: "" + checkstyle_classpath: + description: | + Classpath for checkstyle. This is needed when your checkstyle configuration uses custom checks that are not included in the default checkstyle distribution. + 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. + default: "" properties_file: description: | 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. diff --git a/entrypoint.sh b/entrypoint.sh index 3f90c38..eff6ddf 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -17,6 +17,11 @@ if [ -n "${INPUT_PROPERTIES_FILE}" ]; then OPTIONAL_PROPERTIES_FILE="-p ${INPUT_PROPERTIES_FILE}" fi +CHECKSTYLE_CLASSPATH="/opt/lib/checkstyle.jar" +if [ -n "${INPUT_CHECKSTYLE_CLASSPATH}" ]; then + CHECKSTYLE_CLASSPATH="${CHECKSTYLE_CLASSPATH}:${INPUT_CHECKSTYLE_CLASSPATH}" +fi + # user wants to use custom Checkstyle version, try to install it if [ -n "${INPUT_CHECKSTYLE_VERSION}" ]; then echo '::group::📥 Installing user-defined Checkstyle version ... https://github.com/checkstyle/checkstyle' @@ -38,7 +43,11 @@ echo '::group:: Running Checkstyle with reviewdog 🐶 ...' { echo "Run check with"; java -jar /opt/lib/checkstyle.jar --version; } | sed ':a;N;s/\n/ /;ba' # shellcheck disable=SC2086 -exec java -jar /opt/lib/checkstyle.jar "${INPUT_WORKDIR}" -c "${INPUT_CHECKSTYLE_CONFIG}" ${OPTIONAL_PROPERTIES_FILE} -f xml \ +exec \ + java \ + -cp ${CHECKSTYLE_CLASSPATH} \ + com.puppycrawl.tools.checkstyle.Main "${INPUT_WORKDIR}" \ + -c "${INPUT_CHECKSTYLE_CONFIG}" ${OPTIONAL_PROPERTIES_FILE} -f xml \ | reviewdog -f=checkstyle \ -name="checkstyle" \ -reporter="${INPUT_REPORTER:-github-pr-check}" \