I've been going through the Ivy documentation and I have a question about the default ivysettings.xml
found inside the ivy.jar.
All I want to do is change the public repository to a local Maven repository we have. That's it. I could copy all of the ivysettings*.xml
files into my project, and use <ivy:settings>
to point to it, but that duplicates a lot of stuff. I could also modify the ivy.jar
, but that adds maintenance headaches. Developers have to use my ivy.jar
, and if we go to a new version, I'd have to modify it again.
So, how do I keep all of the standard Ivy settings and simply switch the repository to use? I simply want to overlay my changes onto what Ivy already has.
And two more questions:
ivyconf*.xml
files and the ivysettings*.xml
files? Why are there duplicate configurations in Ivy?That's my ivysettings.xml file
<ivysettings>
<include url="${ivy.default.settings.dir}/ivysettings.xml"/>
<resolvers>
<chain name="download-chain" changingPattern=".*" checkmodified="true" >
<ibiblio name="maven" m2compatible="true" />
</chain>
</resolvers>
</ivysettings>
Notice that I write my extra resolvers here, but use everything else from the standard one, which is indicated in the url. This will loads the settings from the ivysettings.xml in the ivy.jar file.
As to the ivyconf*.xml. I think it is deprecated now. Ivysettings is the new way of doing this.
The resources are pretty awful. I totally concur to that. However, lots of answers in the stackoverflow.com were verbose enough and actually try to anticipate problems
Mark O'Connor's answers are particularly verbose and straight to the point. You have to embrace the fact that you are learning something new, just give it time.
Finally figured it out.
I copied the ivysettings.xml file from the jar and made a slight modification. Note that the first include points to an XML file in ivy ${ivy.lib.dir}
and not to ${ivy.default.settings.dir}
:
<ivysettings>
<settings defaultResolver="default"/>
<include file="${ivy.lib.dir}/ivysettings-public.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
</ivysettings>
I have my own ivysettings-public.xml
which is the same as the default, but now defines a root
to my repository. (Yes, it's localhost for now, but I'll set it to an actual server once I get everything resolved):
<ivysettings>
<resolvers>
<ibiblio name="public" m2compatible="true"
root="http://localhost:8081/artifactory/repo" />
</resolvers>
</ivysettings>
Now, in my build.xml
, I have the following:
<property name="ivy.lib.dir" value="${basedir}/ivy.lib"/>
<taskdef uri="ivylib:org.apache.ivy.ant"
resource="org/apache/ivy/ant/antlib.xml">
<classpath>
<fileset dir="${ivy.lib.dir}">
<include name="ivy.jar"/>
<include name="ivy-*.jar"/>
</fileset>
</classpath>
</taskdef>
<ivy:configure file="${ivy.lib.dir}/ivysettings.xml" override="true"/>
That seems to do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With