【发布时间】:2015-12-02 21:08:52
【问题描述】:
我正在 Eclipse 中使用 Java 多模块项目。而且我必须为我的 Maven 构建配置 Checkstyle,并在出现任何违规时使构建失败。 我在这个网站上找到了使用本教程的推荐:https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html 我决定遵循它。
我已将新的子文件夹 build-tools 添加到我的 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 install 给了我成功,但我不得不因为违规而使项目失败。我哪里错了?也许我给我的 checkstyle.xml 写了错误的路径?请帮帮我。
【问题讨论】:
标签: java xml eclipse maven checkstyle