[英]resolving tools.jar in ivy
i have a project that uses ivy to manage its dependencies. 我有一个使用常春藤来管理其依赖项的项目。 i'm implementing a feature to the project that requires me to include tools.jar.
我正在为项目实现一个要求我包含tools.jar的功能。 however, because tools.jar is platform dependent, i'm trying to use ivy to resolve to a local file for the artifact.
但是,因为tools.jar是依赖于平台的,所以我试图使用常春藤来解析工件的本地文件。 i'm doing the following:
我正在做以下事情:
<dependency org="com.sun" names="tools" rev="1.6.0">
<artifact name="tools" type="jar" url="file:///${java.home}/../lib/tools.jar"/>
</dependency>
that should retrieve the file from the local ${java.home}/../lib/tools.jar. 应该从本地$ {java.home} /../ lib / tools.jar中检索文件。 (note: java.home points to the JRE installation).
(注意:java.home指向JRE安装)。
however, there are problems resolving the location. 但是,解决位置存在问题。 on my windows machine, it seems to think "c" is the protocol (c is coming from ${java.home}. and i'm sure that my url is defined correctly because "file:///C:/foo" is the correct way to specify a url to a file (3 slashes). the problem i see is that it strips off 2 slashes and tries "file:/C:..." instead of "file:///C:.." as i specify above. i also tried specifying the path to the file directly w/o the ${java.home}
在我的Windows机器上,似乎认为“c”是协议(c来自$ {java.home}。我确定我的url被正确定义,因为“file:/// C:/ foo”是指定文件的URL的正确方法(3个斜杠)。我看到的问题是它剥离了2个斜杠并尝试“file:/ C:...”而不是“file:/// C:。 。“正如我在上面指定的那样。我也尝试直接用$ {java.home}指定文件的路径
i would like to keep this approach retrieving through ivy, but i can't get it to work. 我想保持这种方法通过常春藤检索,但我无法让它工作。 any ideas?
有任何想法吗?
JAVA_HOME needs to point at the location of your JDK, not your JRE. JAVA_HOME需要指向JDK的位置,而不是JRE。 Once you change this, ANT will stop complaining about a missing tools jar.
一旦你改变了这一点,ANT将停止抱怨丢失的工具罐。
Looking at the path you provide above, I suspect that you already have a JDK installed.... 看看你上面提供的路径,我怀疑你已经安装了JDK ....
On my system the tools jar is located here: 在我的系统上,工具罐位于:
$ find $JAVA_HOME -name tools.jar
/usr/lib/jvm/java-6-openjdk/lib/tools.jar
Oddly, and confusing, the Java JDK ships with a JRE inside 奇怪而且令人困惑的是,Java JDK里面装有JRE
$ find $JAVA_HOME -name java
/usr/lib/jvm/java-6-openjdk/bin/java
/usr/lib/jvm/java-6-openjdk/jre/bin/java
I was able to get this to work using a dedicated resolver 我能够使用专用的解析器来实现这一点
ivysettings.xml ivysettings.xml
<resolvers>
<!-- your other resolvers here -->
<filesystem name="JDK" local="true">
<artifact pattern="${java.home}/lib/[artifact].[type]" />
<artifact pattern="${java.home}/../lib/[artifact].[type]" />
<!-- You can add more patterns to fit your needs for MacOSX etc -->
</filesystem>
</resolvers>
<modules>
<module organisation="com.sun" name="tools" resolver="JDK"/>
</modules>
ivy.xml 的ivy.xml
<dependency org="com.sun" name="tools"/>
Works for me... 对我有用......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.