【问题标题】:Disable maven checkstyle, pmd for groovy sources in multimodule project为多模块项目中的 groovy 源禁用 maven checkstyle、pmd
【发布时间】:2013-08-26 19:22:50
【问题描述】:

我有一个多模块 maven 项目,但我找不到禁用 pmd 的方法,用于 groovy 源的 checktyle。

我确实从顶层运行了一个命令:

mvn clean install pmd:pmd checktyle:checkstyle

我的项目结构是:

pom.xml
-module1
 src
   main
      groovy          
   test
      groovy

-module2
 src
   main
      groovy
      java
  test
      groovy

我不希望 pmd/checkstyle 检查我的 groovy 文件。 这是 pluginManagement 中的父 pom 部分:

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>2.7.1</version>
    <configuration>
        <format>xml</format>
        <targetJdk>1.6</targetJdk>
        <linkXRef>false</linkXRef>
        <!--
          <excludeRoots>
            <excludeRoot>${project.basedir}/src/main/groovy</excludeRoot>
            <excludeRoot>${project.basedir}/src/test/groovy</excludeRoot>
          </excludeRoots>
        -->
        <!--
        <excludeRoots>
          <excludeRoot>
           ${project.basedir}/target/generated-sources/groovy-stubs
          </excludeRoot>
        </excludeRoots>
        -->
        <excludes>
           <exclude>**/generated-sources/groovy-stubs/**/*.java</exclude>
        </excludes>
      <rulesets>
       <ruleset>
        ${rule.repository.url}/pmd/rules/pmd-rules/1.0.4.2/pmd-rules-1.0.4.2.xml
       </ruleset>
      </rulesets>
     </configuration>
 </plugin>

module1 在它的 pom.xml 中没有任何对 pmd/checktyle 插件的引用。无论如何 pmd,检查样式​​应用于 groovy 源。

module2 在它的 pom.xml 中确实引用了这些插件,而且 groovy 仍然没有被忽略。

我做错了什么?

【问题讨论】:

  • 试着用包含来表达你想要包含的东西,而不是试图排除东西
  • 如果我只指定“包含”,它将完全停止工作:)

标签: java groovy maven-3 checkstyle pmd


【解决方案1】:

如果您使用调试选项 (-X) 运行 Maven,您可以看到 PMD 插件处理过的所有目录。所有目录都列在变量 compileSourceRoots 中。

您可以使用这些排除项来为 groovy-stub 禁用 PMD:

<excludeRoots>
    <excludeRoot>${project.build.directory}/generated-sources/groovy-stubs/main</excludeRoot>
    <excludeRoot>${project.build.directory}/generated-sources/groovy-stubs/test</excludeRoot>
</excludeRoots>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-02
    • 2014-12-20
    • 1970-01-01
    • 1970-01-01
    • 2011-11-24
    • 1970-01-01
    • 2011-02-01
    • 1970-01-01
    相关资源
    最近更新 更多