Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ivysettings.xml: Can I "modify" the default settings without modifying the jar or completely replacing them?

Tags:

ivy

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:

  • What's the difference between the ivyconf*.xml files and the ivysettings*.xml files? Why are there duplicate configurations in Ivy?
  • What's a good book on Ivy? I'm right now using Manning's Ant in Action which covers Ivy in a somewhat summary way and is a bit dated. The resources on the Ivy website itself are awful.
like image 970
David W. Avatar asked Jul 13 '12 16:07

David W.


2 Answers

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.

like image 169
Eyad Ebrahim Avatar answered Oct 02 '22 08:10

Eyad Ebrahim


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.

like image 22
David W. Avatar answered Oct 02 '22 08:10

David W.