4

I got a strange problem. I added Guava to my ivy.xml as the following:

<dependency org="com.google.guava" name="guava" rev="14.0.1" conf="test"/>

When I run ant, I can see it's resolved:

[ivy:retrieve]  found com.google.guava#guava;14.0.1 in default

And I can find the file in the ~/.ivy2/cache. But it didn't get copied to my lib directory.

Other dependencies have no problem....Any advice? Thanks.

compass
  • 327
  • 3
  • 15

3 Answers3

1

Specify the configuration mapping in ivy.xml

I had the same problem and couldn't for the life of me figure out where the dependencies were downloaded to. Ivy seemed to suggest it was downloaded, and there were some entries in the cache, but nothing was appearing in my /lib.

---------------------------------------------------------------------
|                  |            modules            ||   artifacts   |
|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
|      compile     |   2   |   2   |   2   |   0   ||   0   |   0   |
---------------------------------------------------------------------

But everything changed when I saw this answer.

In ivy.xml, you have to specify the configuration mapping conf="myconfig->default", the key being ->default

<configurations>
    <conf name="myconfig" description="Required for JSF"/>
</configurations>

<dependencies>
    <dependency conf="myconfig->default" name="jsf-api" org="com.sun.faces" rev="2.2.13"/>          
</dependencies>

This will map your user-defined configuration to a Maven scope (to be exact, the default scope). In practice, you will only use either default or master scope (source).

See:

My gut feel is that this is only required if you are pointing to an Maven repository. I have not tried otherwise.

If you have already done this and it still does not download, perhaps @javabrett's answer can help.

Community
  • 1
  • 1
typoerrpr
  • 1,626
  • 21
  • 18
0

If you truly used <ivy:retrieve />, not just resolve, then it's probably because you need to use conf="test->default" ?

Patrice M.
  • 4,209
  • 2
  • 27
  • 36
  • @compass This is the most likely explanation. If you supply your ivy.xml file we can confirm it's related to the way you have setup configurations. For a more illustrative retrieve task example see: http://stackoverflow.com/questions/4071009/split-retrieved-artifacts-in-two-separate-lib-directories/4092120#4092120 – Mark O'Connor May 11 '13 at 12:22
0

This is caused by the Maven packaging-type for com.google.guava:guava:14.0.1 being the OSGi bundle rather than jar. There is an Ivy bug for this that has been resolved, but the solution is not complete.

You need to avoid specifying type="jar" and instead use type="jar,bundle" if you want to download both package-types.

See also this question and the POM definition.

Community
  • 1
  • 1
javabrett
  • 7,020
  • 4
  • 51
  • 73