0

I just did a very ugly hack.

I have a module A which produces two jars.

moduleA.jar and moduleA.test.jar

The module.test.jar is used by other projects in the same repository and won't be published further to other repositories.

I added this to ivy.xml of moduleA

<publications>
    <artifact name="moduleA" type="jar" ext="jar" conf="compile"/>

    <artifact name="moduleA.test" type="jar" ext="jar" conf="test"/>
</publications>

How can I consume that in moduleB . I understand that Maven doesn't support multiple artifacts per module, and I read somewhere that this is supported by IVY. I just don't seem to get it write.

I tried this in ivy.xml of moduleB:

<dependency org="my.org" name="moduleA" rev="SNAPSHOT" conf="compile,test->default,test" />
<dependency org="my.org" name="moduleA.test" rev="SNAPSHOT" conf="compile,test->default,test" />

But this obviously didn't work, since 'name' is the name of the module not artifact. I had a work around using the type attribute: in moduleA:

<artifact name="moduleA" type="test.jar" ext="jar" conf="test"/>

and in moduleB:

<dependency org="my.org" name="moduleA" rev="SNAPSHOT" conf="compile,test->default,test" />

This worked, but looks very ugly. since I have to produce the file in ANT looking like this:

moduleA-SNAPSHOT.test.jar

any neat solution to depending on multiple artifacts of the same module?

This question id different from: How do I solve Multiple artifacts of the module X are retrieved to the same file in Apache Ivy?

Community
  • 1
  • 1
Eyad Ebrahim
  • 971
  • 1
  • 8
  • 21

1 Answers1

1

Assuming that Module A looks like this:

<info organisation="my.org" module="moduleA" .../>

<configurations>
    <conf name="compile description="???"/>
    <conf name="test    description="???"/>
    ..
</configurations>

<publications>
    <artifact name="moduleA" type="jar" ext="jar" conf="compile"/>
    <artifact name="moduleA.test" type="jar" ext="jar" conf="test"/>
</publications>

The following Module B declaration will retrieve the moduleA.jar

<dependency org="my.org" name="moduleA" rev="latest.integration" conf="default->compile" />

The following Module B declaration will retrieve the moduleA.test.jar

<dependency org="my.org" name="moduleA" rev="latest.integration" conf="default->test" />

It's the configuration mappings that make it work:

default->compile
^          ^
|          |
Local configuration
           |
           Remote configuration

The local configuration doesn't have to be "default". Obviously if Module B also uses configurations, you could use one of those.

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • It worked like magic thanks. Another general thing I learned from this, is to not confuse the confmapping conf1,conf2,conf3->conf1,conf2,conf3 is bad bad practice – Eyad Ebrahim Jul 30 '12 at 11:46