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

3

8

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.
Gasman answered 13/7, 2012 at 16:55 Comment(0)
G
1

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.

Gasman answered 13/7, 2012 at 20:17 Comment(1)
you shouldn't be copying the usual ivysettings.xml. You could do the <include url="${ivy.default.settings.dir}/ivysettings.xml" /> that I wrote in my answer. And then do what you gotta do. I have to say though. These basics are covered in the examples inside the apach-ivy downloadable src.Rosol
R
7

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.

Rosol answered 13/7, 2012 at 20:12 Comment(3)
I know it'll take me time to pick it up, but even the very basics are poorly explained. This would be the very first question someone would have if they'Gasman
do I get this right: <include url="${ivy.default.settings.dir}/ivysettings.xml"/> points to the ivysettings.xml in the jar? Because I've never set the variable ivy.default.settings.url and I also have nowhere an ivysettings.xml on my filesystem.Sweepings
that was long time ago, but run ant with -d or -v and it should show lots of info including variables and properties' valuesRosol
G
1

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.

Gasman answered 13/7, 2012 at 20:17 Comment(1)
you shouldn't be copying the usual ivysettings.xml. You could do the <include url="${ivy.default.settings.dir}/ivysettings.xml" /> that I wrote in my answer. And then do what you gotta do. I have to say though. These basics are covered in the examples inside the apach-ivy downloadable src.Rosol
B
0

In your build.xml include following:

<property name="ivy.settings.dir" value="PATH OF SETTINGS" />
<property file="${ivy.settings.dir}/ivysettings.properties" />
<ivy:settings file="${ivy.settings.dir}/ivysettings.xml" />
Babcock answered 11/1, 2013 at 3:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.