将特定jar检索到文件夹

时间:2013-01-10 14:50:37

标签: ivy

我是从常春藤缓存中检索一个jar到一个lib文件夹,下面是ivy.xml代码:

    <configurations>
        <conf name="specificFolder"  description="add jar to web-inf/lib folder"/>
    </configurations>
    <dependencies>
        <dependency org="javax.servlet" name="servlet-api" rev="2.4" transitive="false" conf="specificFolder"/>
        <dependency org="org.springframework" name="spring-beans" rev="2.5.5" transitive="false" />
        <dependency org="org.springframework" name="spring-webmvc" rev="2.5.5" transitive="false" />
        <dependency org="org.springframework" name="spring-web" rev="2.5.5" transitive="false" />
        <dependency org="org.springframework" name="spring-context" rev="2.5.5" transitive="false" />
        <dependency org="org.springframework" name="spring" rev="1.2.6" transitive="false" />

然后这是蚂蚁目标:

<target name="test">
    <ivy:retrieve pattern="lib/[artifact](.[ext])" sync="true" type="jar" conf="specificFolder"/>
</target>

但我得到了“未解决的依赖”,这是我做错了什么?

1 个答案:

答案 0 :(得分:2)

我重现了您的问题,这是相关的错误消息:

[ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve]       ::          UNRESOLVED DEPENDENCIES         ::
[ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve]       :: javax.servlet#servlet-api;2.4: configuration not found in javax.servlet#servlet-api;2.4: 'specificFolder'. It was required from com.myspotontheweb#demo;????? specificFolder
[ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::

根本原因是以下依赖声明:

<dependency org="javax.servlet" name="servlet-api" ... conf="specificFolder"/>

虽然模块中存在配置,但远程Maven模块中不存在该配置。有关如何查看以下答案的更多详细信息:

工作示例

的ivy.xml

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="demo"/>

    <configurations>
        <conf name="specificFolder"  description="add jar to web-inf/lib folder"/>
    </configurations>
    <dependencies>
        <dependency org="javax.servlet" name="servlet-api" rev="2.4"            conf="specificFolder->master"/>
        <dependency org="org.springframework" name="spring-beans" rev="2.5.5"   conf="specificFolder->master"/>
        <dependency org="org.springframework" name="spring-webmvc" rev="2.5.5"  conf="specificFolder->master"/>
        <dependency org="org.springframework" name="spring-web" rev="2.5.5"     conf="specificFolder->master"/>
        <dependency org="org.springframework" name="spring-context" rev="2.5.5" conf="specificFolder->master"/>
        <dependency org="org.springframework" name="spring" rev="1.2.6"         conf="specificFolder->master"/>
    </dependencies>

</ivy-module>

注意:

  • 此示例使用配置映射而不是“transitive = false”。本地配置是“specificFolder”,远程配置是特殊的“master”。 “master”由Maven模块提供,表示没有依赖关系的远程工件。一旦了解配置如何工作,我认为这种方法更简单。 (Maven中非常强大的概念)
  • what does the little arrow -> do in the ivy dependency section?