我希望Ivy能够同时获取log4j .jar和JavaDocs。现在,我走到了尽头。如果我在ivy.xml中使用它...
<dependency org="log4j" name="log4j" rev="1.2.16"/>
...然后我得到.jar文件。但是当使用这个ivysettings.xml ...
时<?xml version="1.0" encoding="UTF-8"?>
<ivysettings>
<settings
defaultResolver="default"
defaultConflictManager="all" />
<resolvers>
<url name="default" m2compatible="true">
<artifact pattern="http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
<artifact pattern="http://repo2.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
</url>
</resolvers>
</ivysettings>
...和这个ivy.xml ......
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="foo" module="bar"/>
<dependencies>
<dependency org="log4j" name="log4j" rev="1.2.16">
<artifact name="log4j" type="jar" ext="jar"/>
<artifact name="log4j" type="javadoc" ext="jar"/>
</dependency>
</dependencies>
</ivy-module>
...然后我收到此错误消息: java.lang.RuntimeException:模块log4j#log4j; 1.2.16的多个工件被检索到同一个文件!更新检索模式以修复此错误。
我在这里缺少什么?我怎样才能让Ivy解析JavaDoc和.jar文件?
编辑: 感谢到目前为止所有快速而详细的回复。这是我更新的ivy.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="foo" module="bar"/>
<configurations>
<conf name="default" visibility="public"/>
<conf name="compile" visibility="public"/>
<conf name="master" visibility="public"/>
<conf name="javadoc" visibility="public"/>
</configurations>
<dependencies>
<dependency org="log4j" name="log4j" rev="1.2.16" conf="default->master,javadoc"/>
<dependency org="javax.servlet" name="servlet-api" rev="2.5" />
<dependency org="com.someother" name="proprietary-core" rev="1.2.3" force="true"/>
<dependency org="com.someother" name="proprietary" rev="1.2.3" force="true"/>
<dependency org="com.someother" name="scanner" rev="1.0" force="true"/>
</dependencies>
</ivy-module>
现在我收到此错误消息:
Buildfile: D:\workspace\foobar\build.xml
resolve:
[ivy:retrieve] :: Ivy 2.2.0 - 20100923230623 :: http://ant.apache.org/ivy/ ::
[ivy:retrieve] :: loading settings :: file = D:\workspace\foobar\ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: foo#bar;working@myhost
[ivy:retrieve] confs: [default, compile, master, javadoc]
[ivy:retrieve] found log4j#log4j;1.2.16 in internal
[ivy:retrieve] found javax.servlet#servlet-api;2.5 in internal
[ivy:retrieve] found com.someother#proprietary-core;1.2.3 in internal
[ivy:retrieve] found com.someother#proprietary;1.2.3 in internal
[ivy:retrieve] found com.someother#scanner;1.0 in internal
[ivy:retrieve] :: resolution report :: resolve 332ms :: artifacts dl 10ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 5 | 0 | 0 | 0 || 4 | 0 |
| compile | 4 | 0 | 0 | 0 || 4 | 0 |
| master | 4 | 0 | 0 | 0 || 4 | 0 |
| javadoc | 4 | 0 | 0 | 0 || 4 | 0 |
---------------------------------------------------------------------
[ivy:retrieve]
[ivy:retrieve] :: problems summary ::
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: UNRESOLVED DEPENDENCIES ::
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: log4j#log4j;1.2.16: configuration not found in log4j#log4j;1.2.16: 'master'. It was required from foo#bar;working@myhost default
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]
[ivy:retrieve]
[ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
Maven范围似乎存在问题。但到底我到底错过了什么?
答案 0 :(得分:7)
问题是您在常春藤检索任务中使用的模式。它需要包含可选的“classifier”属性以确保文件名是唯一的:
<ivy:retrieve pattern="lib/[conf]/[artifact](-[classifier]).[ext]"/>
分类器是一个Maven的东西,用于识别与Maven模块相关的其他人工制品。
无需复杂的常春藤设置。配置映射控制从其他模块下载哪些人工制品。
删除 ivysettings.xml 文件,然后在 ivy.xml 中尝试以下操作:
<dependency org="log4j" name="log4j" rev="1.2.16" conf="default->master,javadoc"/>
这会导致下载以下文件:
它是如何运作的?
对于Maven模块,ivy会创建一个与每个标准Maven范围匹配的配置:
并另外为模块发布的每个附加工件(或分类器)创建配置:
这使您可以混合搭配。