0

I am running into issues similar to [https://stackoverflow.com/questions/25432810/error-when-trying-to-use-org-codehaus-mojocobertura-maven-plugin2-6].

LOGS: Execution default-cli of goal org.codehaus.mojo:cobertura-maven-plugin:2.6:instrument failed: Plugin org.codehaus.mojo:cobertura-maven-plugin:2.6 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:0 at specified path /usr/local/Cellar/openjdk/15.0.2/libexec/openjdk.jdk/Contents/Home/../lib/tools.jar

RESEARCH:

When I do java --version, I get: java 11.0.6 2020-01-14 LTS

Upon searching SO, I found that since I am on the JDK 11, the tools.jar has been removed [https://stackoverflow.com/a/60549167/13241701]. When I run the jacoco, the test cases run. But

ISSUE: I want to report the cobertura coverage report only.

Can I get some help?

harry123
  • 760
  • 1
  • 7
  • 22

1 Answers1

0

I would recommend using latest version of the plugin which is 2.7 and has built in fixes for java 11.

If you cannot use latest plugin for some reason, here are some of the things you can try

Use 'mvn dependency:tree' to find where that jar is being called and exclude it like so

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>${struts2.version}</version>
    <exclusions>
        <exclusion>
            <artifactId>tools</artifactId>
            <groupId>com.sun</groupId>
        </exclusion>
    </exclusions>
</dependency>

Or you can just reference it in your mvn like

<dependency>
   <groupId>com.sun</groupId>
   <artifactId>tools</artifactId>
   <version>1.6</version>
   <scope>system</scope>
   <systemPath>C:\Program Files\Java\jdk1.11.6\lib\tools.jar</systemPath>
 </dependency>

where system path is link to your lib

Another way is to provide jdk vm as a run arg

-vm "C:\Program Files\Java\jdk1.11.6\bin"
  • Still getting: `Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (default-cli) on project fb-connector: Execution default-cli of goal org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument failed: Plugin org.codehaus.mojo:cobertura-maven-plugin:2.7 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:0 at specified path /usr/local/Cellar/openjdk/15.0.2/libexec/openjdk.jdk/Contents/Home/../lib/tools.jar` `mvn dependency:tree` is not showing `com.sun`. Further, I am on mac. thanks – harry123 Mar 29 '21 at 17:14