Hello all,

I wonder what the recommended way to include tools.jar (or any other JAR
packaged with the JDK but not normally included in the classpath) would be.

Typically, I would define a dependency on the form:

        <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>${java.version}</version>
            <scope>system</scope>
            <systemPath>${toolsjarSystemPath}</systemPath>
        </dependency>

... and then use a set of profiles to define the actual toolsjarSystemPath,
to cope with the fact that different JDKs could (or still can(?)) use
different packaging for the tools.jar:

<profile>
            <id>standardToolsJar-profile</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <file>
                    <exists>${java.home}/../lib/tools.jar</exists>
                </file>
            </activation>
            <properties>

<toolsjarSystemPath>${java.home}/../lib/tools.jar</toolsjarSystemPath>
            </properties>
        </profile>
        <profile>
            <id>appleJdkToolsJar-profile</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <file>
                    <exists>${java.home}/../Classes/classes.jar</exists>
                </file>
            </activation>
            <properties>

<toolsjarSystemPath>${java.home}/../Classes/classes.jar</toolsjarSystemPath>
            </properties>
        </profile>

While the approach above works, it tends to produce the following error
message when maven is run:

[ERROR] Artifact: com.sun:tools:jar:1.7.0_65 has no file.

So ... is there a better approach? (Not counting JDK 9 just yet).

-- 

--
+==============================+
| Bästa hälsningar,
| [sw. "Best regards"]
|
| Lennart Jörelid
| EAI Architect & Integrator
|
| jGuru Europe AB
| Mölnlycke - Kista
|
| Email: l...@jguru.se
| URL:   www.jguru.se
| Phone
| (skype):    jgurueurope
| (intl):     +46 708 507 603
| (domestic): 0708 - 507 603
+==============================+

Reply via email to