簡體   English   中英

如何分析 Maven pom.xml 的錯誤(冗余或忽略屬性的 pom linter?)

[英]How to analyze a Maven pom.xml for mistakes (a pom linter for redundant or ignored properties?)

我的pom.xml很亂,隨着時間的推移收集了垃圾。 有沒有自動化的方法來“清理”一個 pom? 就像一個短絨,但用於 maven。

在 IntelliJ 中,我可以運行Analyze > Inspect Code並獲取未使用函數、愚蠢的迭代器和可能的錯誤的列表。 我想我正在為我的 pom 尋找同樣的東西

  1. 未使用的存儲庫,pluginRepositories
  2. 未使用的屬性
  3. 與插件中指定的設置沖突的屬性
  4. 具有較新版本的依賴項( mvn versions:display-dependency-updates有效,但不限於非破壞性版本更新)

對於 pom.xml 的簡單pom.xml分析,您可以使用lint-maven-plugin

  1. 將以下內容添加到您的pom.xml
<build>
  <plugins>
    <plugin>
      <groupId>com.lewisd</groupId>
      <artifactId>lint-maven-plugin</artifactId>
      <version>0.0.11</version>
    </plugin>
  </plugins>
</build>
  1. 運行lint:check目標以檢查您的pom.xml是否存在違規行為。
$ mvn lint:check

該插件將報告您的pom.xml中的任何違規行為,如下所示。

[INFO] --- lint-maven-plugin:0.0.11:check (default-cli) @ maven-sample ---
[INFO] Writing summary report
[INFO] [LINT] Completed with 3 violations
[INFO] [LINT] OSSDevelopersSectionRule: missing <developers/> section : 0:0 : /Users/jdoe/workspace/maven-sample/pom.xml
[INFO] [LINT] OSSInceptionYearRule: missing <inceptionYear/> information : 0:0 : /Users/jdoe/workspace/maven-sample/pom.xml
[INFO] [LINT] GAVOrder: Found 'name' but was expecting 'packaging' : 19:8 : /Users/jdoe/workspace/maven-sample/pom.xml

您可以通過運行lint:list目標來查看可用規則的列表。

聽起來沒有像 jshint.com 這樣的 pom.xml 短絨,我可以將我的 pom 粘貼到其中並獲得建議。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM