Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include a file in ivy.xml?

Tags:

ant

ivy

I have a fairly large ivy.xml containing a number of configurations which are the same for a number of projects.

I would like to break out this large repetitive section in to a common include file. Somehow I can't find any documentation describing that this can be done.

Anyone who has an idea whether this is doable?

EDIT: After some further thinking, I think this is not doable on purpose. An Ivy file is meant to be one cohesive unit and should contain no file based references, only references to other ivy modules...

like image 663
Christer Fahlgren Avatar asked Nov 19 '09 04:11

Christer Fahlgren


1 Answers

You could create an ivy meta-module, which depends upon all of those common packages, and then have all your other projects resolve the common libraries through transitive dependency:

    <?xml version="1.0"?>
    <ivy-module version="2.0">
        <info organisation="com.example" module="common-libs"/>
          <configurations>
            <conf name="runtime" transitive="true" visibility="public" />
            <conf name="master" transitive="true" visibility="public" />
            <conf name="compile" transitive="true" visibility="public" />
            <conf name="default" transitive="true" visibility="public" extends="master" />
          </configurations>
          <dependencies>
                <dependency org="oracle" name="ojdbc14_g" rev="10.2.0.3"
 conf="compile->compile(*),master(*);runtime->runtime(*);master->master(*)"/>
                <dependency org="tomcat" name="servlet-api" rev="6.0.16" 
 conf="compile->compile(*),master(*);runtime->runtime(*);master->master(*)"/>
                <dependency org="junit" name="junit" rev="4.3"
 conf="compile->compile(*),master(*);runtime->runtime(*);master->master(*)"/>
          </dependencies>
    </ivy-module>

And for a typical project:

<?xml version="1.0"?>
    <ivy-module version="2.0">
    <info organisation="com.example" module="myproject"/>
      <configurations>
        <conf name="runtime" transitive="true" visibility="public" />
        <conf name="master" transitive="true" visibility="public" extends="runtime"/>
        <conf name="compile" transitive="true" visibility="public" />
        <conf name="default" transitive="true" visibility="public" extends="master" />
      </configurations>
      <dependencies>
        <dependency org="com.example" name="common-libs" rev="latest.release" 
          conf="compile->compile(*),master(*);runtime->runtime(*);master->master(*)"/>
      </dependencies>
    </ivy-module>

Here I'm using the traditional configuration naming conventions from the POM->Ivy translations of the Maven resolver, though you could map the configuration names in any way that made sense to you. I tend to use the ivy:install task to copy Maven modules into our Ivy repository, so I use the default ivy.xmls for the most part. If you're using IvyRoundup, you'll primarily want to map the "default" configuration transitively.

like image 111
Kirby Files Avatar answered Oct 15 '22 07:10

Kirby Files