【问题标题】:Maven - FindBugs Plugin - Exclude from Test PhaseMaven - FindBugs 插件 - 从测试阶段排除
【发布时间】:2012-03-07 15:59:29
【问题描述】:

我的 Maven 设置中的 findbugs 插件工作正常。我已经设置 findbugs 在编译阶段执行。但是我注意到它也在测试阶段运行,因为测试阶段也调用编译。因为我有一个运行所有目标的自动构建管道,所以在测试阶段我不需要 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>

【问题讨论】:

    标签: maven findbugs pom.xml


    【解决方案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,而不是将其从通常的构建区域中删除并放入报告区域。

    【讨论】:

    • 我在第二个 部分的测试阶段遇到了 findbugs 的问题。我添加了第二个 以便我可以将其设置为 测试阶段。换句话说,如果我删除了包含测试阶段的第二个 ,如果我发出 mvn test,findbugs 仍然会运行。
    • 问题是为什么要在编译周期中运行 findbugs?通常的用例是在站点生成期间运行它。简单的问题是:你想什么时候运行 findbugs ?
    • 感谢您抽出宝贵时间讨论此问题。我想在编译期间运行它,这样如果发现新的错误,构建可能会失败。站点生成不是正常设置的一部分。只有当一切都构建并正确通过所有测试时,我才会生成该站点。请注意,我的工作不是“站点”,而是后端服务器,因此在我的案例中严格使用站点来生成项目信息和报告。
    • 基于此我会说你应该使用阶段“进程类”,如果在编译之后。
    猜你喜欢
    • 1970-01-01
    • 2012-01-04
    • 1970-01-01
    • 2010-10-04
    • 1970-01-01
    • 2011-10-26
    • 2012-07-07
    • 2016-01-18
    • 1970-01-01
    相关资源
    最近更新 更多