优化:引入 spotless 插件(代码等格式化插件),已对现有代码执行了格式优化(mvn spotless:apply)

This commit is contained in:
2022-12-10 13:43:49 +08:00
parent e55d7edb34
commit 4ed8ba4709
7 changed files with 352 additions and 29 deletions

45
pom.xml
View File

@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -22,6 +37,7 @@
<properties>
<!-- ### 基础环境相关 ### -->
<java.version>1.8</java.version>
<spotless.version>2.28.0</spotless.version>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -86,6 +102,35 @@
<!-- 设置构建的 jar 包名 -->
<finalName>${project.name}</finalName>
<plugins>
<!-- 代码等格式化插件 -->
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless.version}</version>
<configuration>
<java>
<importOrder>
<order>java,javax,org,com,top.charles7c,</order>
</importOrder>
<removeUnusedImports/>
<eclipse>
<file>${project.basedir}/code-style/spotless-formatter.xml</file>
</eclipse>
<licenseHeader>
<file>${project.basedir}/code-style/license-header</file>
</licenseHeader>
</java>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>apply</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 单元测试配置插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>