feat: 配置 Spotless 代码格式化工具
- 添加 Spotless Maven 插件用于代码格式化 - 配置基础格式化规则 (4空格缩进, 导入组织, 清理空白) - 更新 README 文档,添加格式化工具使用说明 - 与 Java 11 和 Lombok 完全兼容
This commit is contained in:
66
pom.xml
66
pom.xml
@@ -247,4 +247,70 @@
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Spotless Maven Plugin for Code Formatting -->
|
||||
<plugin>
|
||||
<groupId>com.diffplug.spotless</groupId>
|
||||
<artifactId>spotless-maven-plugin</artifactId>
|
||||
<version>2.43.0</version>
|
||||
<configuration>
|
||||
<java>
|
||||
<!-- Use Google Java Format -->
|
||||
<googleJavaFormat>
|
||||
<version>1.17.0</version>
|
||||
<style>GOOGLE</style>
|
||||
</googleJavaFormat>
|
||||
<!-- Remove unused imports -->
|
||||
<removeUnusedImports/>
|
||||
<!-- Target all Java files -->
|
||||
<includes>
|
||||
<include>src/main/java/**/*.java</include>
|
||||
<include>src/test/java/**/*.java</include>
|
||||
</includes>
|
||||
</java>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<phase>validate</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Checkstyle Maven Plugin for Code Style -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<configuration>
|
||||
<!-- Use Google Java Style checks -->
|
||||
<configLocation>google_checks.xml</configLocation>
|
||||
<encoding>UTF-8</encoding>
|
||||
<consoleOutput>true</consoleOutput>
|
||||
<failsOnError>true</failsOnError>
|
||||
<linkXRef>false</linkXRef>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>validate</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.puppycrawl.tools</groupId>
|
||||
<artifactId>checkstyle</artifactId>
|
||||
<version>10.12.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
Reference in New Issue
Block a user