Ivy cached a dependency file, but not copy to my lib

女生的网名这么多〃 提交于 2020-01-03 17:20:30

问题


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.


回答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:

  • Official description: http://ant.apache.org/ivy/history/2.2.0/ivyfile/configurations.html
  • IMHO a clearer explanation: http://wrongnotes.blogspot.sg/2014/02/simplest-explanation-of-ivy.html
  • This answer discusses maven scopes other than default: https://stackoverflow.com/a/7116577/4212710

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.




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/16491229/ivy-cached-a-dependency-file-but-not-copy-to-my-lib

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!