idea 代码格式化 Spotless 教程
生活随笔
收集整理的這篇文章主要介紹了
idea 代码格式化 Spotless 教程
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
介紹
接入
下載 check code xml
intellij-java-google-style.xml
pom引入spotless 插件
<plugin><groupId>com.diffplug.spotless</groupId><artifactId>spotless-maven-plugin</artifactId><version>2.22.1</version><configuration><java><eclipse><file>${maven.multiModuleProjectDirectory}/src/resources/intellij-java-google-style.xml</file></eclipse><licenseHeader><file>${maven.multiModuleProjectDirectory}/src/resources/license-header</file></licenseHeader></java></configuration><!-- 將 Spotless apply 綁定到 compile 階段,這樣本地執行 mvn install 時就能自動格式化。--><executions><execution><goals><goal>apply</goal></goals><phase>compile</phase></execution></executions> </plugin>Spotless 支持格式化指定目錄,以及排除指定目錄的功能,詳情參考spotless-maven-plugin。如無指定,執行 check 或 apply 時,默認項目全量代碼。
檢驗
#格式化 mvn spotless:apply # 檢查 mvn spotless:check開發過程中 格式化 文件
問題
Spotless 與 Checkstyle 可能沖突,那要看取舍調整了
總結
以上是生活随笔為你收集整理的idea 代码格式化 Spotless 教程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Intellij IDEA 代码格式化配
- 下一篇: IDEA代码格式化校验