With Java11 and Maven, try to avoid jacoco and surefire exit error and run jacoco test coverage on Mac

Viewed 1449

This seems to be an issue related to Mac, Java11. I am trying to run source code and target as Java8 but my runtime is java 11

Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T14:49:05-05:00) Maven home: /Users/user/Documents/tools/apache-maven-3.5.3 Java version: 11.0.6, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/Contents/Ho

Issue with Jacoco

Now with this configuration, I cannot run jacoco,

Error is: Skipping JaCoCo execution due to missing execution data file.

Issue with Surefire error

I also have to put this in my pom.xml to avoid an error below.

Added snippet.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <!-- Remove snippet below, fix jacoco?  But get jdk11 error? -->
    <version>2.21.0</version>
    <configuration>
        <forkCount>3</forkCount>
        <reuseForks>true</reuseForks>
        <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
    </configuration>
</plugin>

Now, I get this error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project pri-prospect-management-batch: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/user/git-main5/pri-prospect-management-batch/app/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?

[ERROR] Process Exit Code: 134
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669)

So I am trying to run jacoco, java11, surefire without errors.

Configs:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven-clean-plugin-version>2.5</maven-clean-plugin-version>
    <maven-compiler-plugin-version>3.3</maven-compiler-plugin-version>
    <maven-dependency-plugin-version>2.8</maven-dependency-plugin-version>
    <maven-install-plugin-version>2.4</maven-install-plugin-version>
    <maven-jar-plugin-version>2.4</maven-jar-plugin-version>
    <maven-resources-plugin-version>2.6</maven-resources-plugin-version>
    <maven-surefire-plugin-version>2.12.4</maven-surefire-plugin-version>
    <maven-war-plugin-version>2.2</maven-war-plugin-version>
    <maven-ear-plugin-version>2.8</maven-ear-plugin-version>
    <java.source.version>1.8</java.source.version>
    <java.target.version>1.8</java.target.version>
    <org.springframework.version>4.3.8.RELEASE</org.springframework.version>
    <jacoco.version>0.7.9</jacoco.version>
    <jackson.version>2.11.2</jackson.version>
</properties>

...

Jacoco

 <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>${jacoco.version}</version>
    <executions>
        <execution>
            <id>prepare-agent</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
        <execution>
            <id>report</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
        <execution>
            <id>post-unit-test</id>
            <phase>test</phase>
            <goals>
                <goal>report</goal>
            </goals>
            <configuration>
                <dataFile>target/jacoco.exec</dataFile>
                <outputDirectory>target/jacoco-ut</outputDirectory>
            </configuration>
        </execution>
    </executions>
    <configuration>
        <excludes>
        </excludes>
    </configuration>
</plugin>
0 Answers
Related