[英]Disable maven checkstyle, pmd for groovy sources in multimodule project
[英]Can't configure Checkstyle in Maven multimodule project
我正在Eclipse中使用Java多模塊項目。 而且我必須將Checkstyle配置為我的Maven構建,並在發生任何違規的情況下使構建失敗。 我在此網站上找到了推薦使用本教程的建議: https : //maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html而且我決定遵循它。
我已經用我的checkstyle.xml添加了新的子文件夾構建工具 ,並在項目的pom.xml中進行了所有更改。
主pom.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ss.ita</groupId>
<artifactId>jresume</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>JResume</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.16</version>
<dependencies>
<dependency>
<groupId>com.softserveinc.ita</groupId>
<artifactId>build-tools</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.16</version>
<configuration>
<configLocation>build-tools/src/main/resources/jresume/checkstyle.xml</configLocation>
<headerLocation>build-tools/src/main/resources/jresume/LICENSE.txt</headerLocation>
<failsOnError>true</failsOnError>
</configuration>
</plugin>
</plugins>
</reporting>
<modules>
<module>common</module>
<module>persistence</module>
<module>business</module>
<module>logging</module>
<module>web</module>
<module>build-tools</module>
</modules>
</project>
當我編寫一些帶有checkstyle違規的Java代碼時, Maven安裝會給我帶來成功,但由於違規,我不得不使項目失敗。 我哪里出問題了? 也許我寫了我的checkstyle.xml錯誤的路徑? 請幫幫我。
將配置更改為:
<configLocation>jresume/checkstyle.xml</configLocation>
<headerLocation>jresume/LICENSE.txt</headerLocation>
這些參數是相對於您的源文件夾而言的。
如果查看com.softserveinc.ita:build-tools:1.0
的jar文件,將會看到沒有src/main/resources
。
另外,您應該安裝/部署com.softserveinc.ita:build-tools:1.0
如果工作區中有項目,Eclipse通常會為您解決此問題,但是我不確定此機制是否可以處理插件的依賴項。
而且,聽起來好像您想在<build>
生命周期(而不是<reporting>
生命周期(站點))中使<build>
失敗。 查看https://maven.apache.org/plugins/maven-checkstyle-plugin/usage.html的最后一部分
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.