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>
引入的重要变化:
<dependency org="??" name="??" rev="??" conf="runtime->default" />
这里我们要说的是,我们希望远程模块的默认依赖项与本地运行时配置相关联
实际上,您实际上只需要两个远程配置映射:
- 默认值:远程模块的工件及其所有运行时可传递依赖项
- 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>
该报告将有助于解释每个依赖项如何在不同的配置上结束。对于确定如何管理可传递依赖项也非常有用
最后,这里是配置继承获得回报的地方,创建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>