Maven - FindBugs插件 - 从测试阶段中排除

时间:2012-03-06 06:59:28

标签: maven findbugs pom.xml

我的findbugs插件在我的maven设置中正常工作。我已经设置了findbugs在编译阶段执行。但是我注意到它在测试阶段也会运行,因为测试阶段也会调用compile。因为我有一个运行所有目标的自动构建管道,所以在测试阶段我不需要运行findbugs。我试图在测试阶段将findbugs排除在外,但没有运气。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <version>2.4.0</version>
    <inherited>true</inherited>
    <configuration>
        <failOnError>${findbugs.failOnError}</failOnError>
        <skip>${findbugs.skip}</skip>
        <trace>${findbugs.trace}</trace>
    </configuration>
    <executions>
        <execution>
            <phase>compile</phase>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
        <execution>
            <id>findbugs-test-compile</id>
            <phase>test</phase>
            <goals>
                <goal>check</goal>
            </goals>
            <configuration>
                <skip>true</skip>
            </configuration>
        </execution>
    </executions>
</plugin>

1 个答案:

答案 0 :(得分:1)

它不会基于运行生命循环来调用它通过编译它只是运行因为你配置了两个执行一个在测试中,一个在编译阶段。 Findbugs通常应该在报告区域(站点)运行。 只需执行一次:

  <executions>
        <execution>
            <id>findbugs-test-compile</id>
            <phase>test</phase>
            <goals>
                <goal>check</goal>
            </goals>
            <configuration>
                <skip>true</skip>
            </configuration>
        </execution>
    </executions>

你喜欢的那个。但我建议阅读documentation因为它应该只在报告区域(通过网站)运行。

更新:
如果您只想在站点生成期间运行findbugs,而不是将其从通常的构建区域中删除,而是将其放入报告区域。