maven:如何以独立于操作系统的方式加载tools.jar / classes.jar? [英] maven: How to load tools.jar/classes.jar in an OS independent way?

查看:210
本文介绍了maven:如何以独立于操作系统的方式加载tools.jar / classes.jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个maven插件,它需要一个包含在jdk(windows)tools.jar中的类(mac它在classes.jar中)。

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将此添加为插件的显式依赖项,如下所示:

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>

如果我使用的是OS X,这是有效的。但是,如果我正在开发,它就不起作用在Windows机器上。而且,我不喜欢使用../Classes。

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.

是否有更好的方法可以加载JDK提供的类?

Is there perhaps a better way to load in the JDK provided classes?

注意:我理解默认(Sun,现在是Oracle)是在lib / tools.jar中使用这些类发布JDK,并且唯一真正的异常值是使用重新打包的Apple JDK开发的那些。尽管如此,我仍然对系统独立方法感兴趣 - 这并不依赖于特定路径。

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.

推荐答案

您可以通过为Windows VS Mac OS定义不同的构建配置文件来实现此目的。
有关详情,请参阅此处。
http://maven.apache.org/guides/introduction /introduction-to-profiles.html

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

这篇关于maven:如何以独立于操作系统的方式加载tools.jar / classes.jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆