本文介绍了ivy:retrieve 选择要使用的ivy.xml 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我调用 ivy:retrieve 时,有没有办法选择要使用的 ivy.xml 文件?

Is there a way to select which ivy.xml file to use when I invoke ivy:retrieve ?

查看 文档 看来我可以使用 settingsRef 属性来选择要使用的 IVY 设置文件,但这不是我想要修改的 ivysettings.xml 文件,而是 ivy.xml.我的用例如下:

Looking at the documentation it appears that I can use the settingsRef property to select which IVY settings file to use but it's not the ivysettings.xml file I wish to modify, rather it's ivy.xml. My use case is the following:

  • 我有一个主要的 ivy.xml 文件,用于获取编译时和运行时依赖项
  • 我还有许多构建工具链依赖项,即某些 Ant 任务本身使用的 jar(例如 findbugs、cobertura、pmd、代码样式合规性检查等).这些东西既不是我的代码的编译时也不是运行时依赖.此外,它在我使用此工具链构建的所有项目中都是相同的,因此我希望能够在一个单独的 ivy.xml 文件中识别这些依赖项,我可以简单地复制该文件我的项目.
  • I have a main ivy.xml file that I use to fetch my compile-time and run-time dependencies
  • I also have a number of build tool-chain dependencies, i.e. jars used by certain Ant tasks themselves (e.g. stuff like findbugs, cobertura, pmd, code style compliance checking etc.). That's stuff that's neither a compile time nor a run-time dependency of my code. Moreover, it's the same in all the projects I am building with this tool chain so I'd like to be able to identify these dependencies in a single, separate ivy.xml file that I can simply copy across my projects.

推荐答案

所以我最后是这样做的:

So this is how I did it in the end:

<target name="fetch-buildsystem-deps" depends="configure-ivy-settings">
    <ivy:resolve file="ivy-buildsystem.xml"/>
    <ivy:retrieve conf="build-system"
                  pattern="${lib-ivy-buildsystem.dir}/[artifact]-[revision](-[classifier]).[ext]"
                  sync="true"
                  type="jar, bundle"/>
</target>

…其中文件 ivy-buildsystem.xml 仅标识我的 Ivy 任务的依赖项.例如.包含以下内容:

… where the file ivy-buildsystem.xml identifies only the dependencies of my Ivy tasks. E.g. contains stuff like:

<configurations>
    <conf name="build-system"  description="artifacts needed by the build-system itself"/>
</configurations>
<dependencies>
    <!--dependency org="ant-contrib" name="ant-contrib" rev="1.0b3" conf="build-system->master"/-->
    <dependency org="com.puppycrawl.tools"     name="checkstyle"   rev="5.9"   conf="build-system->default"/>
    <dependency org="com.google.code.findbugs" name="findbugs-ant" rev="3.0.0" conf="build-system->default"/>
    <dependency org="net.sourceforge.pmd"      name="pmd-java"     rev="5.5.3" conf="build-system->default"/>

</dependencies>

这篇关于ivy:retrieve 选择要使用的ivy.xml 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 06:28