diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2e89b21fc0e..a9c322957c0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -90,6 +90,9 @@ jobs:
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
+ - name: Spotless
+ run: ./mvnw spotless:check
+
- name: Build Keycloak
uses: ./.github/actions/build-keycloak
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e0458235378..c0cac41469a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -110,6 +110,33 @@ git commit --signoff --message "This is the commit message"
This option adds a `Signed-off-by` trailer at the end of the commit log message.
+### Spotless
+
+Spotless is used to check and apply code formatting. To check your code locally before sending a PR run:
+
+```
+./mvnw spotless:check
+```
+
+You can either use your IDE to fix these issues; or Spotless can fix them for you by running:
+
+```
+./mvnw spotless:apply
+```
+
+A good practice is to create a commit with your changes prior to running `spotless:apply` then you can see and
+review what changes Spotless has applied, for example by using a diff tool. Finally, if you are happy with the changes
+Spotless has applied you can amend the changes to your commit by running:
+
+```
+git add -a
+git commit --amend
+```
+
+Note: If you get the error `Could not find goal 'verify' in plugin com.diffplug.spotless:spotless-maven-plugin` you are
+probably running `mvn spotless:check` instead of `./mvnw spotless:check`. This is most likely a bug in Maven or the
+Spotless plugin.
+
### Commit messages and issue linking
The format for a commit message should look like:
diff --git a/boms/pom.xml b/boms/pom.xml
index 5a54a03310e..a9f5de04ddb 100644
--- a/boms/pom.xml
+++ b/boms/pom.xml
@@ -47,6 +47,7 @@
0.7.0
1.0.7
+ 3.0.0
@@ -77,6 +78,11 @@
${jboss.repo.nexusUrl}
+
+ com.diffplug.spotless
+ spotless-maven-plugin
+ ${spotless-plugin.version}
+
diff --git a/pom.xml b/pom.xml
index 3e9f3b4bcff..0a528f0bb07 100644
--- a/pom.xml
+++ b/pom.xml
@@ -207,6 +207,7 @@
3.6.2
6.3.0
3.2.0
+ 3.0.0
512m
@@ -1518,8 +1519,19 @@
${skipProtoLock}
+
+ com.diffplug.spotless
+ spotless-maven-plugin
+ ${spotless-plugin.version}
+
+
+
+
+
+
+