From my searching, I found supporting information here: Java Development Guide for Mac OS X
tools.jar
does not exist. Classes usually lo
I faced the same problem, and resolved it differently.
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents
and not
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Add the cobertura plugin, make sure systemPath
is correctly ref the location of classes.jar
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${java_home}/Classes/classes.jar</systemPath>
</dependency>
</dependencies>
</plugin>
Add the dependency and exclude tools
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
</exclusion>
</exclusions>
</dependency>
Finally add the following profiles
<profiles>
<profile>
<id>standard-jdk</id>
<activation>
<file>
<exists>${java_home}/Home/lib/tools.jar</exists>
</file>
</activation>
<properties>
<tools-jar>${java_home}/Home/lib/tools.jar</tools-jar>
</properties>
</profile>
<profile>
<id>apple-jdk</id>
<activation>
<file>
<exists>${java_home}/Classes/classes.jar</exists>
</file>
</activation>
<properties>
<tools-jar>${java_home}/Classes/classes.jar</tools-jar>
</properties>
</profile>
Now run maven and it should successfully generate the Cobertura reports!
This is similar to Bruno's answer above; however, I am not a big fan of symlinking the absolute path. Here is how I handle the symlinks:
cd /Library/Java/JavaVirtualMachines/<jdk version>/Contents/Home
sudo ln -s lib Classes
cd lib/
sudo ln -s tools.jar classes.jar
That makes it easier then symlinking absolute paths.
Well, you search for 'tools.jar', with grep for instance. If the place where classes.jar is, where tools.jar was expected, you could just change the word.
Another idea is, to create a symbolic link from classes.jar to tools.jar, if you have enough privileges and the file system(s) on MacOS support this. Else: copy. Might be more easy, but not be forgotten for updates, maybe.
Here is my tested solution, which implies no change in maven config, just add symbolic links:
Enjoy! Bruno
Can't find any references to it on the interweb, but my Mac 1.7 and 1.8 jdk's now have tools.jar.
/Library/Java/JavaVirtualMachines/jdk1.7.0_12.jdk/Contents/Home/lib/tools.jar /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/lib/tools.jar /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/tools.jar /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/lib/tools.jar /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/lib/tools.jar /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar
classes.jar is only present in mac 1.6 jdk.
--Erik
Instead of using Tomcat from Macports download Tomcat from Apache.
6.0: http://tomcat.apache.org/download-60.cgi
7.0: http://tomcat.apache.org/download-70.cgi