How to include a dependency to tools.jar in Maven?
Case
You need include tools.jar
as a dependency in a pom.xml, for instance in order to use Java 5’s annotations and APT. From a “Maven’s view point”, tools.jar
is not a regular JAR defined by a groupId
and artefactId
.
Solution
Add this block in your pom.xml
:
[xml]<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6.0_24</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>[/xml]
(You can also add it in your settings.xml
)
You can do the same for any other “non-regular” JAR, available in your file system.