Cobertura doesn't work with Java 7

后端 未结 3 2029
我寻月下人不归
我寻月下人不归 2021-01-19 01:23

I am using maven 3.0.4, JRE 1.7.0_09. When I use mvn clean install all my tests passes and everything looks good - here is my surefire plugin confi

相关标签:
3条回答
  • 2021-01-19 01:31

    We are using Cobertura plugin version 2.6 with Java 7 with no problems. This includes some files with Java 7 syntax (multi-catch, e.g.) which used to fail with the earlier plugin version. Nor do I need to use -XX:-UseSplitVerifier in the SureFire plugin any longer.

    <properties>
        <coberturaMavenPlugin>2.6</coberturaMavenPlugin>
        <mavenSurefirePlugin>2.12</mavenSurefirePlugin>
    </properties>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${mavenSurefirePlugin}</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>${coberturaMavenPlugin}</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
        </plugins>
    </reporting>
    
    0 讨论(0)
  • 2021-01-19 01:35

    Further to this, the issue we had was to do with Cobertura and the version of Xalan/Xerces.

    Looking at http://mojo.codehaus.org/cobertura-maven-plugin/dependencies.html, it can be seen that the cobertura plugin has Transitive Dependencies on Xalan 2.6.0 & Xerces at 2.6.2.

    To combat this, I added:

    <dependency>
        <groupId>xalan</groupId>
        <artifactId>xalan</artifactId>
        <version>2.7.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.11.0</version>
        <scope>test</scope>
    </dependency>
    

    And the tests passed, both during the initial test phase with surefire and the cobertura phase.

    0 讨论(0)
  • 2021-01-19 01:35

    Perhaps you can set the compiler source and target version options to version "1.6" Different versions of build tools may choose different defaults for this setting. (Buildr 1.4 defaults to source and target 1.7 these days; Maven 2.x still uses 1.6 or earlier.)

    0 讨论(0)
提交回复
热议问题