简体   繁体   中英

Keep a parameterized path on maven tools.jar dependency

We have a custom taglet for our javadocs that requires tools.jar as a dependency, but maven hardcodes the jar location in the released pom.xml.

For that dependency in maven we use the ${java.home} parameter in our pom.xml , but after the project is built the path for that tools.jar is hardcoded to whatever JDK it was built with:

cat ~/.m2/repository/.../client.pom
...
    <dependency>
        <groupId>com.sun</groupId>
        <artifactId>tools</artifactId>
        <version>1.4.2</version>
        <scope>system</scope>
        <systemPath>/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/../lib/tools.jar</systemPath>
    </dependency>

I've thought about changing the scope to test but then we can't use the ${java.home} parameter.

Is there a way to either keep the parameterized path, reconfigure the pom/project so the javadocs are separate, or make maven realize it won't need it at runtime?

Maven supports custom taglets directly using the maven-javadoc-plugin .

For more information, please see the official Maven documentation . It is so clearly described that it doesn't make sense repeating the code here. This can be setup in the <report> section or the <build> section. Within the <build> section, you would likely need to custom tie it to the appropriate build phase too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM