2
<ivy-module version="2.0">
    <info organisation="com.travelclick" module="CoreWebServices" revision="4.1"/>
    <configurations defaultconfmapping="default">
        <conf name="runtime" visibility="public"/>
        <conf name="default" visibility="public"  extends="runtime"/>
    </configurations>

    <dependencies>
        <dependency org="com.travelclick"
            name="commons-all"
            rev="4.1"
            conf="default->default"/>

        <dependency org="com.sun.messaging.mq"
            name="jms"
            rev="4.5.2"
            conf="default->default"/>

        <dependency org="org.jboss.common"
            name="servlet-api"
            rev="4.2"
            conf="default->default"/>

        <dependency org="com.fiorano"
            name="framework"
            rev="2.0"
            conf="default->default"/>

        <dependency org="com.fiorano"
            name="fmq-client"
            rev="9.3.0"
            conf="default->default"/>

        <dependency org="commons-codec"
            name="commons-codec"
            rev="1.3"
            conf="default->default"/>

        <dependency org="commons-httpclient"
            name="commons-httpclient"
            rev="3.1"
            conf="default->default"/>

        <dependency org="commons-lang"
            name="commons-lang"
            rev="2.2"
            conf="default->default"/>

        <dependency org="commons-pool"
            name="commons-pool"
            rev="1.4"
            conf="default->default"/>
    </dependencies>
</ivy-module>

Note that all dependencies are configured as default->default.

In my build.xml, I have the following statements:

 <ivy:resolve conf="default"/>
 <ivy:cachepath pathid="all.libs" conf="default"/>

Note I'm using the default configuration.

I use the all.libs path to download the libraries into my war I'm building.

I get the following libraries in my war, which is what I want:

commons-all-4.1.jar
commons-codec-1.3.jar
commons-httpclient-3.1.jar
commons-lang-2.2.jar
commons-logging-1.0.4.jar
commons-pool-1.4.jar
fmq-client-9.3.0.jar
framework-2.0.jar
jms-4.5.2.jar
servlet-api-4.2.jar

Now, I'll remove the configuration information. This is the same ivy.xml with the <configurations> section removed and all the conf=default->default removed:

<ivy-module version="2.0">
    <info organisation="com.travelclick" module="CoreWebServices" revision="4.1"/>

    <dependencies>
        <dependency org="com.travelclick"
            name="commons-all"
            rev="4.1"/>

        <dependency org="com.sun.messaging.mq"
            name="jms"
            rev="4.5.2"/>

        <dependency org="org.jboss.common"
            name="servlet-api"
            rev="4.2"/>

        <dependency org="com.fiorano"
            name="framework"
            rev="2.0"/>

        <dependency org="com.fiorano"
            name="fmq-client"
            rev="9.3.0"/>

        <dependency org="commons-codec"
            name="commons-codec"
            rev="1.3"/>

        <dependency org="commons-httpclient"
            name="commons-httpclient"
            rev="3.1"/>

        <dependency org="commons-lang"
            name="commons-lang"
            rev="2.2"/>

        <dependency org="commons-pool"
            name="commons-pool"
            rev="1.4"/>
    </dependencies>
</ivy-module>

Naturally, I also have to change by build.xml to remove references to the default configuration:

 <ivy:resolve/>
 <ivy:cachepath pathid="all.libs"/>

But, now look what gets included:

commons-all-4.1.jar
commons-codec-1.3.jar
commons-httpclient-3.1.jar
commons-lang-2.2.jar
commons-logging-1.0.4.jar
commons-pool-1.4.jar
fmq-client-9.3.0.jar
framework-2.0.jar
jms-4.5.2.jar
servlet-api-4.2.jar

commons-httpclient-3.1-sources.jar
commons-codec-1.3-javadoc.jar
commons-codec-1.3-sources.jar
commons-lang-2.2-javadoc.jar
commons-lang-2.2-sources.jar
commons-pool-1.4-sources.jar

Why, when I set everything to default, only the actual jars downloaded and not the source and javadoc jars. Yet, when I removed all configuration, the javadoc and source jars also downloaded.

In fact, where is the configuration of the various jars in the Maven repository stored? I can see the javadoc and source in the Maven repository, but I didn't see anything about various configurations. How does Ivy know whether or not to include the sources and javadoc jars?

David W.
  • 105,218
  • 39
  • 216
  • 337
  • The mention of Maven in the last paragraph came as a late surprise. How is Maven involved here? Your Ivy module file above makes no mention of using a Maven repository. Does your Ivy settings file include such configuration? – seh Jul 16 '12 at 20:14
  • @seh: Ivy can use Maven repositories for both getting jars and for distribution of jars. I use [Artifactory](http://www.jfrog.com/home/v_artifactory_opensource_overview). Some of those jars are company owned jars and aren't in the standard Maven repo. I added them into our Artifactory repo. – David W. Jul 17 '12 at 01:53

1 Answers1

3

There is no standard default configuration in ivy. Each ivy file defines its own set of confs in the <configuration> ..</configuration> section.

In your first example you defined default and mapped it to the default configuration of your artifacts. These dependencies are maven artifacts and ivy maps a maven scope to default (Ivy reads the maven pom file and creates an ivy file for that in the cache). So basically you were just lucky, that the default conf existed in the ivy file for the configuration.

The conf default is a mapped maven scope and does not exist as a pre-defined standard conf in ivy.

In your second example you omit the conf="default->default", which is equivalent to conf="*->*" and means: map everything in the dependency to every conf in this ivy file.

This question answers how ivy maps maven scopes to ivy configurations.

In Short:

  • default maps to the maven scope default which just references the jar
  • declaring no scopes maps to the ivy configuration *, which references all available configurations and therefore all available maven artifacts.
Community
  • 1
  • 1
oers
  • 18,436
  • 13
  • 66
  • 75
  • Ah! Thanks. Now it's makes sense. I was looking for configuration information in the repo, but I goes that's just an Ivy thing. What you're saying is that the _default_ configuration isn't the actual _default_ configuration in Ivy. – David W. Jul 17 '12 at 01:58
  • Just wanted to add that the links were also very useful. Thanks again. It clears up a lot of my confusion about Ivy. – David W. Jul 17 '12 at 13:57