2015-09-07 59 views
2

我正在使用Eclipse中的Java multimodule项目。而且我必须将Checkstyle配置到我的Maven构建中,并且在发生任何违规时都会使构建失败。 我发现这个网站上的推荐使用这个教程:https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html我决定跟着它。无法在Maven多模块项目中配置Checkstyle

我已经添加了新的子文件夹构建工具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> 

当我写一些检查式违规的java代码Maven安装给了我SUCCES但我必须失败项目b由于违规行为。我哪里出错了?也许我写了错误的路径到我的checkstyle.xml?请帮帮我。

回答

0

更改配置到:

<configLocation>jresume/checkstyle.xml</configLocation> 
    <headerLocation>jresume/LICENSE.txt</headerLocation> 

这些参数是相对于你的源文件夹(S)。

如果你看看com.softserveinc.ita:build-tools:1.0的jar文件,你会看到没有src/main/resources

此外,你应该安装/部署com.softserveinc.ita:build-tools:1.0如果您在工作区项目的Eclipse通常会为您解决问题,但我不能确定这是否机制依赖工程插件

此外,听起来好像您要在<build>生命周期期间生成失败,而不是<reporting>生命周期(站点)。查看https://maven.apache.org/plugins/maven-checkstyle-plugin/usage.html的最后一段