cobertura-maven-plugin与FindBugs冲突

拉斐尔·维尔泽兹(RafałWrzeszcz)

cobertura-maven-plugin2.6更新2.7后, Cobertura插件与FindBugs插件发生冲突。FindBugs插件在cobertura仪表代码中检测到错误:

[INFO] Incorrect lazy initialization of static field pl.chilldev.sites.commons.ErrorCode.__cobertura_counters in pl.chilldev.sites.commons.ErrorCode.__cobertura_init() [pl.chilldev.sites.commons.ErrorCode] In ErrorCode.java

(将Cobertura插件版本设置为2.6时,一切正常)

以防万一,FindBugs插件版本为3.0.1。

是否可以将这些插件设置为以某种方式协同工作?

编辑1(pom.xml)

这是pom.xml主项目目录(子模块仅包含依赖项列表):

<?xml version="1.0" encoding="utf-8"?>
<!--
# This file is part of the pl.chilldev.sites.
#
# @copyright 2015 © by Rafał Wrzeszcz - Wrzasq.pl.
-->
<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/maven-v4_0_0.xsd
">
    <modelVersion>4.0.0</modelVersion>

    <!-- core project settings -->
    <groupId>pl.chilldev.sites</groupId>
    <artifactId>sites</artifactId>
    <packaging>pom</packaging>
    <version>0.0.1-SNAPSHOT</version>

    <!-- project meta info -->
    <name>ChillDev-Sites</name>
    <url><!-- TODO --></url>
    <description>Content sites storage service.</description>
    <inceptionYear>2015</inceptionYear>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <organization>
        <name>Rafał Wrzeszcz - Wrzasq.pl</name>
        <url>http://wrzasq.pl/</url>
    </organization>

    <!-- plugins configuration -->
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <archive>
                            <index>true</index>
                            <manifest>
                                <addClasspath>true</addClasspath>
                            </manifest>
                            <manifestEntries>
                                <url>${project.url}</url>
                                <Specification-Title>${project.name}</Specification-Title>
                                <Specification-Version>${project.version}</Specification-Version>
                                <Specification-Vendor>Rafał Wrzeszcz - Wrzasq.pl; Chillout Development</Specification-Vendor>
                                <Implementation-Title>${project.name}</Implementation-Title>
                                <Implementation-Version>${project.version}</Implementation-Version>
                                <Implementation-Vendor>Rafał Wrzeszcz - Wrzasq.pl; Chillout Development</Implementation-Vendor>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerArgs>
                        <arg>-Xlint:all</arg>
                    </compilerArgs>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <escapeString>\</escapeString>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                            <goal>cpd-check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.15</version>
                <dependencies>
                    <!-- Maven Checkstyle plugin has a 6.1.1 version by default which is buggy -->
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>6.5</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <configLocation>src/main/checkstyle/checkstyle.xml</configLocation>
                    <propertyExpansion>checkstyle.project.basedir=${project.basedir}</propertyExpansion>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.4</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.doxia</groupId>
                        <artifactId>doxia-module-markdown</artifactId>
                        <version>1.6</version>
                    </dependency>

                    <dependency>
                        <groupId>lt.velykis.maven.skins</groupId>
                        <artifactId>reflow-velocity-tools</artifactId>
                        <version>1.1.1</version>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.velocity</groupId>
                        <artifactId>velocity</artifactId>
                        <version>1.7</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pdf-plugin</artifactId>
                <version>1.3</version>
                <!-- TODO:
                    - fix rendering of company and project logos
                    - add UTF-8 font
                -->
                <executions>
                    <execution>
                        <phase>site</phase>
                        <goals>
                            <goal>pdf</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <effort>Max</effort>
                    <threshold>Low</threshold>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

    <!-- reporting plugins -->
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.8</version>
                <configuration>
                    <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.2</version>
                <configuration>
                    <show>private</show>
                    <excludePackageNames>test.pl.chilldev.sites.*</excludePackageNames>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.4</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.15</version>
                <configuration>
                    <configLocation>src/main/checkstyle/checkstyle.xml</configLocation>
                    <propertyExpansion>checkstyle.project.basedir=${project.basedir}</propertyExpansion>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.5</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.18.1</version>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <!-- TODO: 2.7 doesn't work well with Findbugs -->
                <version>2.6</version>
                <configuration>
                    <formats>
                        <format>html</format>
                    </formats>
                    <instrumentation>
                        <excludes>
                            <exclude>test/**/*.class</exclude>
                        </excludes>
                    </instrumentation>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <effort>Max</effort>
                    <threshold>Low</threshold>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

    <!-- project dependencies -->
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <!-- components of the project -->
    <modules>
        <module>sites-backend</module>
        <module>sites-commons</module>
        <module>sites-core</module>
        <module>sites-frontend</module>
        <module>sites-rpc-client-backend</module>
        <module>sites-rpc-client-frontend</module>
        <module>sites-rpc-service</module>
    </modules>
</project>

编辑2(ErrorCode.java)

package pl.chilldev.sites.commons;

/**
 * JSON-RPC error codes.
 */
public class ErrorCode
{
    /**
     * Dummy code that represents successful operation - should not be used at all.
     */
    public static final int OK = 0;

    /**
     * No entity of specified ID exists.
     */
    public static final int NO_ENTITY = 1;
}
马特斯·巴尔布斯(Mateusz Balbus)

Cobertura 2.7进行了更改project.build.outputDirectory,以生成用于集成测试的报告(2.7中引入了新的报告类型)。在下一步中,Findbugs不仅检查已编译类的违规情况,还检查已检测的违规情况。

查看错误:

http://jira.codehaus.org/browse/MCOBERTURA-203

作为解决方法,您可以覆盖classFilesDirectory

...
<build>
...
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>3.0.1</version>
            <configuration>
                <effort>Max</effort>
                <threshold>Low</threshold>
                <classFilesDirectory>${project.build.outputDirectory}</classFilesDirectory>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
...
</build>
...

另一个解决方案是跳过集成测试报告,而仅继续进行单元测试报告:

http://mojo.codehaus.org/cobertura-maven-plugin/usage.html#Using_different_reports

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用Java 8的cobertura-maven-plugin

来自分类Dev

无法在intelliji中导入cobertura-maven-plugin

来自分类Dev

cobertura-maven-plugin无法找到我的常规代码

来自分类Dev

使用Maven插件生成Cobertura报告

来自分类Dev

Maven目标进行cobertura分析和安装

来自分类Dev

SonarQube:使用Maven上传Cobertura结果

来自分类Dev

使用ROME依赖项和cobertura-maven-plugin防止“ MVN站点”目标中的测试错误

来自分类Dev

通过Maven命令行生成多种Cobertura报告格式

来自分类Dev

代码覆盖率:Cobertura和SonarQube 5.3 Maven集成

来自分类Dev

Cobertura Maven插件生成汇总报告不起作用

来自分类Dev

Maven-将Cobertura报告部署到Confluence Wiki

来自分类Dev

使用Maven插件生成Cobertura-report报告

来自分类Dev

通过Maven命令行生成多种Cobertura报告格式

来自分类Dev

代码覆盖率:Cobertura和SonarQube 5.3 Maven集成

来自分类Dev

如何将Cobertura与Cucumber jvm和Maven结合使用?

来自分类Dev

Cobertura Eclipse Plugin Local site - Download as Zip

来自分类Dev

如何停止findbugs-maven-plugin验证querydsl生成的类

来自分类Dev

如何停止findbugs-maven-plugin验证querydsl生成的类

来自分类Dev

org.codehaus.mojo:findbugs-maven-plugin丢失

来自分类Dev

如何将pluginList指定为findbugs-maven-plugin的Maven依赖项

来自分类Dev

Cobertura Maven插件在Windows上因“命令行太长”而失败

来自分类Dev

为什么Scalatest,Maven和cobertura的代码覆盖率为零?

来自分类Dev

如何使用Maven和Bamboo在Sonar 4.5.2中获得Cobertura的覆盖率?

来自分类Dev

API与SonarQube 5.6和具有Findbugs 3.3或Cobertura 1.6.3的Java Analyzer 4.0不兼容

来自分类Dev

解决与Maven的库冲突

来自分类Dev

Maven中的冲突库

来自分类Dev

单元测试通过Maven,但未通过Cobertura:“预期分支目标65处的堆栈映射框架”

来自分类Dev

cobertura maven插件不能与接口中的java8默认方法声明一起使用吗?

来自分类Dev

GWT(Maven)项目:依赖冲突

Related 相关文章

  1. 1

    使用Java 8的cobertura-maven-plugin

  2. 2

    无法在intelliji中导入cobertura-maven-plugin

  3. 3

    cobertura-maven-plugin无法找到我的常规代码

  4. 4

    使用Maven插件生成Cobertura报告

  5. 5

    Maven目标进行cobertura分析和安装

  6. 6

    SonarQube:使用Maven上传Cobertura结果

  7. 7

    使用ROME依赖项和cobertura-maven-plugin防止“ MVN站点”目标中的测试错误

  8. 8

    通过Maven命令行生成多种Cobertura报告格式

  9. 9

    代码覆盖率:Cobertura和SonarQube 5.3 Maven集成

  10. 10

    Cobertura Maven插件生成汇总报告不起作用

  11. 11

    Maven-将Cobertura报告部署到Confluence Wiki

  12. 12

    使用Maven插件生成Cobertura-report报告

  13. 13

    通过Maven命令行生成多种Cobertura报告格式

  14. 14

    代码覆盖率:Cobertura和SonarQube 5.3 Maven集成

  15. 15

    如何将Cobertura与Cucumber jvm和Maven结合使用?

  16. 16

    Cobertura Eclipse Plugin Local site - Download as Zip

  17. 17

    如何停止findbugs-maven-plugin验证querydsl生成的类

  18. 18

    如何停止findbugs-maven-plugin验证querydsl生成的类

  19. 19

    org.codehaus.mojo:findbugs-maven-plugin丢失

  20. 20

    如何将pluginList指定为findbugs-maven-plugin的Maven依赖项

  21. 21

    Cobertura Maven插件在Windows上因“命令行太长”而失败

  22. 22

    为什么Scalatest,Maven和cobertura的代码覆盖率为零?

  23. 23

    如何使用Maven和Bamboo在Sonar 4.5.2中获得Cobertura的覆盖率?

  24. 24

    API与SonarQube 5.6和具有Findbugs 3.3或Cobertura 1.6.3的Java Analyzer 4.0不兼容

  25. 25

    解决与Maven的库冲突

  26. 26

    Maven中的冲突库

  27. 27

    单元测试通过Maven,但未通过Cobertura:“预期分支目标65处的堆栈映射框架”

  28. 28

    cobertura maven插件不能与接口中的java8默认方法声明一起使用吗?

  29. 29

    GWT(Maven)项目:依赖冲突

热门标签

归档