[英]Failed to bypass maven checkstyle plugin
我的項目由兩個模塊組成,一個是通用的,另一個我們稱之為 X。
當使用 maven 來“全新安裝”模塊 X 時,它抱怨:
You have 50 Checkstyle violations.
查看 pom.xml 我沒有看到任何 checkstyle maven 插件,但在“common”模塊中我確實在“common”的 pom.xml 中找到了它:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
</plugin>
由於模塊 X 依賴於模塊“common”,我在 pom.xml 中更新了 common 的 checkstyle 插件,如下所示:
<configuration>
<skip>true</skip>
</configuration>
並在 X 模塊上運行“全新安裝”之前重建通用模塊。
為了安全起見,我在運行 X 模塊時在 mvn 命令上又添加了一項設置:
mvn clean install -DskipTests -Dcheckstyle.skip
然而,看起來“common”的 pom.xml w.r.t checkstyle 插件的變化和 mvn 命令的附加設置都對運行沒有任何影響 - 它仍然抱怨相同。
我試過pluginManagment
,它工作正常。 您需要將此添加到您的父pom
文件中。
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
原來pom.xml中有兩個地方涉及到checkstyle插件:一個在tag下
<pluginManagement>
,我在其中添加:
<skip>true</skip>
然而這還不夠(至少在我的情況下),我發現 checkstyle 也被注冊在:
<build><plugins>
看起來像:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>6.1.1</version>
</dependency>
</dependencies>
<configuration>
<skip>true</skip>
....
</configuration>
<plugin>
現在,在我將 skip being true 添加到兩個地方並重建項目模塊后,錯誤消失了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.