Support style/format checking on test phase
Description
Enforce formatting rules at test phase.
Implementation ideas
variables:
MAVEN_FORMAT_TOOLS: com.spotify.fmt:fmt-maven-plugin:check
# MAVEN_FORMAT_TOOLS: net.revelc.code.formatter:formatter-maven-plugin:validate
java-test-fmt:
stage: test
script:
- if [[ -f "$JMAVEN_FORMAT_FILE" ]]; then
export MAVEN_FORMAT_OPTS="${MAVEN_FORMAT_OPTS} -DconfigFile=${MAVEN_FORMAT_FILE}"
fi
- mvn ${MAVEN_FORMAT_TOOLS} ${MAVEN_FORMAT_OPTS}
revelc support a -DconfigFile parameters that should be compatible with a gitlab file variable.
Both plugin support a format goal, so it may be interesting to print out the format command when an error occured so the developer can fix it easily.