[英]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.