jdk.tools wrapper

Universal dependency to build against jdk.tools (AKA tools.jar) in a portable way

License

License

Categories

Categories

Java Languages Maven Build Tools
GroupId

GroupId

com.github.olivergondza
ArtifactId

ArtifactId

maven-jdk-tools-wrapper
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

jdk.tools wrapper
Universal dependency to build against jdk.tools (AKA tools.jar) in a portable way
Project URL

Project URL

https://github.com/olivergondza/maven-jdk-tools-wrapper
Source Code Management

Source Code Management

https://github.com/olivergondza/maven-jdk-tools-wrapper

Download maven-jdk-tools-wrapper

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.olivergondza/maven-jdk-tools-wrapper/ -->
<dependency>
    <groupId>com.github.olivergondza</groupId>
    <artifactId>maven-jdk-tools-wrapper</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.olivergondza/maven-jdk-tools-wrapper/
implementation 'com.github.olivergondza:maven-jdk-tools-wrapper:0.1'
// https://jarcasting.com/artifacts/com.github.olivergondza/maven-jdk-tools-wrapper/
implementation ("com.github.olivergondza:maven-jdk-tools-wrapper:0.1")
'com.github.olivergondza:maven-jdk-tools-wrapper:jar:0.1'
<dependency org="com.github.olivergondza" name="maven-jdk-tools-wrapper" rev="0.1">
  <artifact name="maven-jdk-tools-wrapper" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.olivergondza', module='maven-jdk-tools-wrapper', version='0.1')
)
libraryDependencies += "com.github.olivergondza" % "maven-jdk-tools-wrapper" % "0.1"
[com.github.olivergondza/maven-jdk-tools-wrapper "0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Maven jdk.tools wrapper

Universal dependency to build against jdk.tools (AKA tools.jar) in a portable way

TL;DR

When maven gives you headaches trying to use some of the tools.jar classes (because the system scoped dependency have different paths in different JDKs or does not even exist), following dependency should get you going:

    <dependency>
      <groupId>com.github.olivergondza</groupId>
      <artifactId>maven-jdk-tools-wrapper</artifactId>
      <version>0.1</version>
    </dependency>

Problem

Prior Jigsaw introduced in Java 9, maven needs to pass the jar on javac classpath at compile time to build projects referring to its classes. Despite the fact the jar is distributed together with JDK, maven needs to be instructed to use it explicitly. system dependency scope is here to do just that but there are still some caveats to keep in mind:

Solution

There are tricks to get this working across Java versions and systems. Maven profiles can distinguish those situations and declare particular dependency if needed. Consult the pom.xml for more details.

As the actual maven wizardry is quite elaborate, surprising to newcomers and a subject of future improvements, it is better not co copy-paste it around. Hence this module exists so you do not have to know or care about the details.

This dependency (hosted on maven central) do not have any runtime footprint (external dependencies, classes loaded) but merely instruct maven what to do on compile time. All the transitive dependencies brought to the client projects are system scoped.

Versions

Version
0.1