Allow .jar tools in ivy

I have a project that uses ivy to manage its dependencies. I am implementing a project function that requires me to enable tools.jar. however, since tools.jar is platform dependent, I am trying to use ivy to allow a local file for an artifact. I do 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> 

which should extract the file from the local $ {java.home} /../ lib / tools.jar. (note: java.home indicates a JRE installation).

however, there are problems resolving the location. on my windows machine, it seems that β€œc” is the protocol (c comes from $ {java.home}. And I'm sure my url is defined correctly, because β€œfile: /// C: / foo” is the correct way is to specify the file url (3 slashes). The problem I see is that it removes 2 slashes and tries "file: / C: ..." instead of "file: /// C: .. "as I indicated above. I also tried to specify the file path directly without $ {java.home}

I would like this approach to come back through ivy, but I can't get it to work. any ideas?

+4
source share
2 answers

JAVA_HOME should point to the location of your JDK, not your JRE. After you change this, ANT will stop complaining about missing jar tools.

Looking at the path that you indicated above, I suspect that you already have JDK installed ....

Analysis

On my system, the jar utility is here:

 $ find $JAVA_HOME -name tools.jar /usr/lib/jvm/java-6-openjdk/lib/tools.jar 

Strange and confusing, the Java JDK comes with a JRE inside

 $ find $JAVA_HOME -name java /usr/lib/jvm/java-6-openjdk/bin/java /usr/lib/jvm/java-6-openjdk/jre/bin/java 
+4
source

I managed to get this to work using a special recognizer

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

 <dependency org="com.sun" name="tools"/> 

Works for me ...

+1
source

Source: https://habr.com/ru/post/1390343/


All Articles