常春藤maven兼容性问题

时间:2014-07-19 00:15:56

标签: maven pom.xml ivy

我试图在Ivy项目中添加依赖项。依赖关系在maven中是这样的:

<dependency>
    <groupId>org.glassfish.jersey.ext</groupId>
    <artifactId>jersey-spring3</artifactId>
    <version>2.7</version>
</dependency>

我已将此添加到ivy.xml文件中:     

但是在运行resolve任务时,它会给我一个这样的错误:         ::::::::::::::::::::::::::::::::::::::::::::::

    ::          UNRESOLVED DEPENDENCIES         ::

    ::::::::::::::::::::::::::::::::::::::::::::::

    :: org.glassfish.hk2#hk2;${hk2.version}: not found

    :: org.glassfish.hk2#spring-bridge;${hk2.version}: not found

    :: javax.ws.rs#javax.ws.rs-api;working@comp: not found

    ::::::::::::::::::::::::::::::::::::::::::::::

Here是jersey-spring3 pom文件。我认为问题是因为pom文件中的父标记。这是因为hk2.version是在jar的父pom中定义的。

Ivy不支持pom文件中的此功能吗? 没有将传递依赖项添加到主ivy.xml的任何方法来解决这个问题? 感谢。

1 个答案:

答案 0 :(得分:0)

无法重现您的问题。下载40个文件没有任何问题。我已将我的常春藤示例包含在下面作为参考。

[ivy:resolve] :: resolution report :: resolve 54551ms :: artifacts dl 25244ms
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      compile     |   40  |   40  |   40  |   0   ||   40  |   40  |
    |      runtime     |   40  |   40  |   40  |   0   ||   39  |   39  |
    |       test       |   40  |   40  |   40  |   0   ||   39  |   39  |
    ---------------------------------------------------------------------

实施例

的ivy.xml

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

    <configurations>
        <conf name="compile" description="Required to compile application"/>
        <conf name="runtime" description="Additional run-time dependencies" extends="compile"/>
        <conf name="test"    description="Required for test only" extends="runtime"/>
    </configurations>

    <dependencies>
        <!-- compile dependencies -->
        <dependency org="org.glassfish.jersey.ext" name="jersey-spring3" rev="2.7" conf="compile->default"/>

        <!-- runtime dependencies -->

        <!-- test dependencies -->
    </dependencies>

</ivy-module>

的build.xml

<project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">

    <!--
    ================
    Build properties
    ================
    -->
    <property name="build.dir" location="build"/>

    <available classname="org.apache.ivy.Main" property="ivy.installed"/> 

    <!--
    ===========
    Build targets
    ===========
    -->
    <target name="install-ivy" description="Install ivy" unless="ivy.installed">
        <mkdir dir="${user.home}/.ant/lib"/>
        <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar"/>
        <fail message="Ivy has been installed. Run the build again"/>
    </target>

    <target name="resolve" depends="install-ivy" description="Use ivy to resolve classpaths">
        <ivy:resolve/>

        <ivy:report todir='${build.dir}/ivy' graph='false' xml='false'/>

        <ivy:cachepath pathid="compile.path" conf="compile"/>
        <ivy:cachepath pathid="test.path"    conf="test"/>
    </target>

    <target name="clean" description="Cleanup build files">
        <delete dir="${build.dir}"/>
    </target>

    <target name="clean-all" depends="clean" description="Additionally purge ivy cache">
        <ivy:cleancache/>
    </target>

</project>