Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant Ivy,主配置是什么?为什么不拉jvyaml?_Ant_Ivy - Fatal编程技术网

Ant Ivy,主配置是什么?为什么不拉jvyaml?

Ant Ivy,主配置是什么?为什么不拉jvyaml?,ant,ivy,Ant,Ivy,我有以下常春藤档案: 我有一个蚂蚁检索任务,看起来像这样: <target name="retrieve-all" depends="resolve"> <ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]" conf="*" /> </target> 奇怪的是,正如我所期望的,所有solr依赖项都下载到lib/runtime中,但是jvyaml模块没有!它“解析”,

我有以下常春藤档案:


我有一个蚂蚁检索任务,看起来像这样:

<target name="retrieve-all" depends="resolve">
    <ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]" conf="*" />
</target>

奇怪的是,正如我所期望的,所有solr依赖项都下载到lib/runtime中,但是jvyaml模块没有!它“解析”,但不会下载到lib/runtime目录,除非我将依赖项声明更改为:

<dependency org="net.java.dev" name="jvyaml" rev="0.2.1" conf="runtime->master" />

这个主配置是什么?为什么需要它来拉jvyaml jar,而不是solr


感谢

请注意,原始solr core也没有检索到。 解析后,转到缓存并检查两个模块的ivy.xml文件

您将看到它们仅在conf=master中发布其工件

<artifact name="jvyaml" type="jar" ext="jar" conf="master"/>

<artifact name="solr-core" type="jar" ext="jar" conf="master"/>

此外

我建议您按如下方式重组配置:

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

    <configurations>
        <conf name="compile" description="Libraries needed only for compilation" />
        <conf name="runtime" description="Libraries only needed at runtime" extends="compile" />
        <conf name="test" description="Libraries only needed for testing" extends="runtime" />
    </configurations>

    <dependencies>
        <dependency org="net.java.dev" name="jvyaml" rev="0.2.1" conf="runtime->default" />
        <dependency org="org.apache.solr" name="solr-core" rev="3.6.0" conf="runtime->default" />
    </dependencies>

</ivy-module>
<target name="init" description="Resolve dependencies and populate lib dir">
    <ivy:resolve/>
    <ivy:report todir="${build.dir}/ivy-report" graph="false"/>
    <ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]"/>
</target>

引入的重要变化:

  • 使用更标准的“编译”配置
  • 配置继承使用“扩展”属性。编译依赖项可以自动包含在运行时和测试配置中
  • 使用配置映射,例如:conf=“runtime->default”。这使得哪个本地配置与哪个远程配置相关联变得显而易见
  • 解释了配置映射 配置是常春藤的一项强大功能。当ivy下载Maven模块时,它会执行内部转换并分配一组标准配置,如下所示:

    在声明依赖项时,最好始终使用配置映射,以便毫无疑问地将依赖项工件分配到何处

    例如:

    <dependency org="??" name="??" rev="??" conf="runtime->default" />
    
    
    
    这里我们要说的是,我们希望远程模块的默认依赖项与本地运行时配置相关联

    实际上,您实际上只需要两个远程配置映射:

    • 默认值:远程模块的工件及其所有运行时可传递依赖项
    • master:仅远程模块的工件(无可传递的依赖项)
    总之,我认为您的问题是由于远程Maven模块的“运行时”范围不包括Maven模块的工件,而您得到的是模块jvyaml的不存在的可传递依赖项:-(

    一些额外的建议 我还建议生成一份常春藤依赖管理报告,如下所示:

    <ivy-module version="2.0">
        <info organisation="com.myspotontheweb" module="demo"/>
    
        <configurations>
            <conf name="compile" description="Libraries needed only for compilation" />
            <conf name="runtime" description="Libraries only needed at runtime" extends="compile" />
            <conf name="test" description="Libraries only needed for testing" extends="runtime" />
        </configurations>
    
        <dependencies>
            <dependency org="net.java.dev" name="jvyaml" rev="0.2.1" conf="runtime->default" />
            <dependency org="org.apache.solr" name="solr-core" rev="3.6.0" conf="runtime->default" />
        </dependencies>
    
    </ivy-module>
    
    <target name="init" description="Resolve dependencies and populate lib dir">
        <ivy:resolve/>
        <ivy:report todir="${build.dir}/ivy-report" graph="false"/>
        <ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]"/>
    </target>
    
    
    
    该报告将有助于解释每个依赖项如何在不同的配置上结束。对于确定如何管理可传递依赖项也非常有用

    最后,这里是配置继承获得回报的地方,创建ivy管理的ANT类路径:

    <target name="init" description="Resolve dependencies and set classpaths">
        <ivy:resolve/>
        <ivy:report todir="${build.dir}/ivy-report" graph="false"/>
    
        <ivy:cachepath pathid="compile.path" conf="compile"/>
        <ivy:cachepath pathid="runtime.path" conf="runtime"/>
        <ivy:cachepath pathid="test.path"    conf="test"/>
    </target>
    

    非常感谢。您解释得非常好。我已经阅读了包括以下内容的大量文档:但最终还是比较困惑。
    <target name="init" description="Resolve dependencies and populate lib dir">
        <ivy:resolve/>
        <ivy:report todir="${build.dir}/ivy-report" graph="false"/>
        <ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]"/>
    </target>
    
    <target name="init" description="Resolve dependencies and set classpaths">
        <ivy:resolve/>
        <ivy:report todir="${build.dir}/ivy-report" graph="false"/>
    
        <ivy:cachepath pathid="compile.path" conf="compile"/>
        <ivy:cachepath pathid="runtime.path" conf="runtime"/>
        <ivy:cachepath pathid="test.path"    conf="test"/>
    </target>