Add Spotless plugin with removeUnusedImports check enabled

Closes #43233

Signed-off-by: stianst <stianst@gmail.com>
This commit is contained in:
stianst
2025-10-03 10:37:38 +02:00
committed by Alexander Schwartz
parent ca368706cc
commit 963682a07c
4 changed files with 48 additions and 0 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -47,6 +47,7 @@
<properties>
<central.publishing.plugin.version>0.7.0</central.publishing.plugin.version>
<nexus3.staging.plugin.version>1.0.7</nexus3.staging.plugin.version>
<spotless-plugin.version>3.0.0</spotless-plugin.version>
</properties>
<distributionManagement>
@@ -77,6 +78,11 @@
<nexusUrl>${jboss.repo.nexusUrl}</nexusUrl>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>

12
pom.xml
View File

@@ -207,6 +207,7 @@
<smallrye.openapi.generator.plugin.version>3.6.2</smallrye.openapi.generator.plugin.version>
<openapi.generator.plugin.version>6.3.0</openapi.generator.plugin.version>
<build-helper-maven-plugin.version>3.2.0</build-helper-maven-plugin.version>
<spotless-plugin.version>3.0.0</spotless-plugin.version>
<!-- Surefire Settings -->
<surefire.memory.Xms>512m</surefire.memory.Xms>
@@ -1518,8 +1519,19 @@
<skip>${skipProtoLock}</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless-plugin.version}</version>
<configuration>
<java>
<removeUnusedImports />
</java>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>