【问题标题】:How to get dependency with Ivy如何获得常春藤的依赖
【发布时间】:2010-11-06 03:46:51
【问题描述】:

我正在审查 Ivy 在我们的应用程序中的使用情况。我已经设置了一个简单的配置来下拉 cobertura。

<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="com"
        module="adesa"
        status="integration">
    </info>
    <configurations>
        <conf name="runtime" description=""/>
    </configurations>
    <dependencies>
      <dependency org="cobertura" name="cobertura" rev="1.8" transitive="true"/>
    </dependencies> 
</ivy-module>

我知道 cobertura 依赖于其他 jar 文件。那么如何获取其他 jar 文件呢?我在缓存目录中看到的唯一内容是 cobertura jar 文件。

这是我的 ivysetting.xml

<ivysettings>
<settings defaultResolver="chained" />
<resolvers>
    <chain name="chained" returnFirst="true"> 
        <url name="apache" m2compatible="true"> 
            <!--Apache -->
            <artifact pattern="http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
            <artifact pattern="http://people.apache.org/repo/m2-incubating-repository/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
        </url>
        <url name="jboss" m2compatible="true">  
            <!-- JBoss -->
            <artifact pattern="http://repository.jboss.com/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
        </url>

        <ibiblio name="ibiblio" m2compatible="true" /> 
        <url name="mvnrepos" m2compatible="true">
            <!-- IBIBLIO-Mirror -->
            <artifact pattern="http://mirrors.ibiblio.org/pub/mirrors/maven2/[organisation]/[module]/[branch]/[revision]/[branch]-[revision].[ext]" />
        </url>
    </chain> 
</resolvers> 

是否有其他可用于获取依赖项/jar 的存储库列表?


来自 build.xml 文件的片段:

    <target name="load-ivy">
    <path id="ivy.lib.path">
        <fileset dir="${basedir}/lib" includes="*.jar"/>
    </path>
    <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>

<target name="ivy-init" depends="load-ivy">
    <mkdir dir="${dest.repo.dir}"/>
    <ivy:settings id="basic.settings" file="${basedir}/ivysettings.xml"/>
</target>

<target name="ivy-clean" depends="ivy-init">
    <ivy:cleancache settingsRef="basic.settings"/>
    <delete dir="${ivy.cache.dir}" failonerror="true"  />
    <delete dir="${dest.repo.dir}"/>
</target>


<target name="ivy-download" depends="ivy-clean,ivy-init">
    <ivy:retrieve  settingsRef="basic.settings" pattern="${dest.repo.dir}/[artifact]/[artifact]-[revision].[ext]" />
</target>

<target name="ivy-report" depends="ivy-download">
    <ivy:report  settingsRef="basic.settings" todir="${basedir}/logs" />
</target>

【问题讨论】:

    标签: java build-process ivy


    【解决方案1】:

    你的 conf 看起来和我的很相似,除了我对 cobertura 有不同的依赖:

    <dependency org="net.sourceforge.cobertura" name="cobertura" rev="1.9" conf="cobertura"/>
    

    另外我建议您在添加额外的存储库之前尝试使用默认的 ivysettings.xml。


    示例 sn-ps

    Ivy 类路径解析:

    <target name="init.deps" description="Download (if needed) and resolve the dependencies." unless="deps.init">
    
        <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.jar.file}" />
    
        <ivy:resolve />
        <ivy:cachepath pathid="ivy.path" conf="production" />
    
        <property name="deps.init" value="true"/> <!-- guard against multiple ivy computations -->
    
    </target>
    

    使用 ivy 路径编译

    <target name="compile" depends="init, record-build-number">
        <javac srcdir="src" debug="true" destdir="build/classes">
            <classpath>
                <path refid="ivy.path" />
            </classpath>
        </javac>
    </target>
    

    【讨论】:

    • 使用你的设置我总是得到:不可能解决依赖关系:消息。我删除了对 ivysettings.xml 的任何引用,并在输出中看到将使用默认实例的消息。
    • 我已经用我的构建文件的一部分编辑了原始消息。我用 mvnrepps 的新模式修改了我的 ivysettings.com,它允许我使用你的依赖项。 mirrors.ibiblio.org/pub/mirrors/maven2/[organisation]/[module]/…" /> mirrors.ibiblio.org/pub/mirrors/maven2/[organisation]/[module]/…" />
    • 你把 ivy:resolve 放在哪里?你能把你的 build.xml 和 ivy.xml 的结构发回作为参考模型吗?
    • 谢谢,我在 ivy.xml 文件中添加了以下内容: 这似乎降低所有依赖的技巧
    猜你喜欢
    • 2013-10-14
    • 2010-10-04
    • 2012-08-05
    • 2011-10-24
    • 2014-05-07
    • 2011-01-23
    • 1970-01-01
    • 2012-01-10
    • 2017-08-06
    相关资源
    最近更新 更多