maven: How to load tools.jar/classes.jar in an OS independent way?
I am using a maven plugin that requires a class that is contained in the jdk开发者_如何转开发's (windows) tools.jar (mac it's in classes.jar).
I add this as an explicit dependency of the plugin as follows:
<dependencies>
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>classes</artifactId>
<version>1.6.0</version>
<scope>system</scope>
<systemPath>${java.home}/../Classes/classes.jar</systemPath>
</dependency>
</dependencies>
This works if I'm using OS X. However, it does not work if I'm developing on a Windows machine. Moreover, I dislike the use of ../Classes.
Is there perhaps a better way to load in the JDK provided classes?
note: I understand the default (Sun, now Oracle) is to ship the JDK with these classes in lib/tools.jar and that the only real outlier is those who develop using the repackaged Apple JDK. Be that as it may, I am still interested in a -system independent approach- that does not depend so much on the specific path.
You can achieve this by defining different build profiles for Windows VS Mac OS. See here for more details. http://maven.apache.org/guides/introduction/introduction-to-profiles.html
It will be interesting how to deal with it in git, because I share .idea dir.
精彩评论