Skip to content

Commit 14f932b

Browse files
committed
feat: add Spotless plugin configuration for code formatting in Maven
1 parent 0eb38df commit 14f932b

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: maven-spotless-check
5+
name: Spotless check (Maven)
6+
entry: bash -c 'mvn -DspotlessFiles=\"$@\" spotless:check' --
7+
language: system
8+
pass_filenames: true
9+
files: "\\.java$"

pom.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,43 @@
264264
<artifactId>versions-maven-plugin</artifactId>
265265
<version>2.8.1</version>
266266
</plugin>
267+
<!-- spotless -->
268+
<plugin>
269+
<groupId>com.diffplug.spotless</groupId>
270+
<artifactId>spotless-maven-plugin</artifactId>
271+
<version>2.43.0</version>
272+
<configuration>
273+
<java>
274+
<includes>
275+
<include>src/main/java/**/*.java</include>
276+
<include>src/test/java/**/*.java</include>
277+
</includes>
278+
<excludes>
279+
<exclude>**/generated/**/*</exclude>
280+
<exclude>**/proto/**/*</exclude>
281+
</excludes>
282+
<googleJavaFormat>
283+
<version>1.17.0</version>
284+
<style>GOOGLE</style>
285+
<reflowLongStrings>true</reflowLongStrings>
286+
<formatJavadoc>true</formatJavadoc>
287+
</googleJavaFormat>
288+
<importOrder>
289+
<order>java,javax,org,com,</order>
290+
</importOrder>
291+
<removeUnusedImports/>
292+
<formatAnnotations/>
293+
</java>
294+
</configuration>
295+
<executions>
296+
<execution>
297+
<goals>
298+
<goal>check</goal>
299+
</goals>
300+
<phase>validate</phase>
301+
</execution>
302+
</executions>
303+
</plugin>
267304

268305
<plugin>
269306
<groupId>org.apache.maven.plugins</groupId>

0 commit comments

Comments
 (0)