Go-based wrapper around Spotless for Java projects.
- Default flow (
check/apply) runs only Java files changed vs--base-branch. - Whole-project flow is explicit with
--all. - Runner parity:
- CI (
CIenv var set): direct Maven - Local: Docker Compose
- CI (
- Local runs default to offline mode (
--offline=true).
cmd/spotless: CLI entrypointpkg/spotless: reusable package and runner logicdev/scripts/entrypoint.spotless.sh: guardrail entrypoint for Spotless containersdev/docker/Dockerfile.spotless: Java/Maven image used by Spotless compose servicesdocker-compose.spotless.yml: Spotless check/apply local servicesMakefile: compatibility wrapper targetsDockerfile: multi-stage Alpine image for thespotlessGo binary
# Changed-files mode (default)
spotless check --repo-dir /path/to/repo --base-branch main
spotless apply --repo-dir /path/to/repo --base-branch main
# Whole-project mode
spotless check --repo-dir /path/to/repo --all
spotless apply --repo-dir /path/to/repo --allCommon flags:
--repo-dir(default.)--offline(defaulttrue)--runner(auto|docker|maven)--remote(defaultorigin)
Validation:
--alland--base-branchare mutually exclusive.--base-branchis required unless--allis used.
# Changed-files mode
make spotless-check TARGET_BASE_BRANCH=main
make spotless-apply TARGET_BASE_BRANCH=main
# Whole-project mode
make spotless-check-all
make spotless-apply-all
# Help and image
make spotless-help
make spotless-buildOptional variables:
REPO_DIR(default.)SPOTLESS_OFFLINE(defaulttrue)
Shortcuts:
make spotless-mainmake spotless-stagingmake spotless-qamake spotless-apply-mainmake spotless-apply-stagingmake spotless-apply-qamake spotless-online TARGET_BASE_BRANCH=<branch>make spotless-offline TARGET_BASE_BRANCH=<branch>make spotless-apply-online TARGET_BASE_BRANCH=<branch>make spotless-apply-offline TARGET_BASE_BRANCH=<branch>
These are used for local formatting runs:
docker-compose.spotless.ymldev/docker/Dockerfile.spotless
Build with:
make spotless-buildBuild the spotless CLI image:
docker build -t jave-spotless:latest .Example:
docker run --rm jave-spotless:latest help- If Docker Compose is missing, install
docker-composeordocker compose. - If
CODE_STYLE_ENV_ENABLEDerrors appear, use Make targets (they set it automatically). - If Maven offline mode misses dependencies, rerun with
SPOTLESS_OFFLINE=falseonce. - If
origin/<branch>is missing locally, changed-files mode may resolve to no files; fetch remotes first when needed.