如何使用依赖于 ivy 导入的 lib 的 Ant taskdef [英] How can I use an Ant taskdef that depends on lib imported by ivy

查看:22
本文介绍了如何使用依赖于 ivy 导入的 lib 的 Ant taskdef的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 build.xml 中创建了一个 taskdef,它依赖于驻留在 Ivy 导入的 jar 中的类.

I've created a taskdef in my build.xml that depends on a class that resides in a jar imported by Ivy.

我想了解一下是否有可能,因为我的构建在开始之前就中断了,因为它找不到 taskdef 的类.

I'd like to understand if it's possible in any way, given the fact that my build breaks before starting because it can't find the class for the taskdef.

这似乎是一个鸡蛋和鸡的问题,因为我无法获得该课程,因为我必须首先解决我的依赖项(这需要构建工作).

This seems a egg and chicken issue, as I can't get the class because I'd have to resolve my dependencies first (which needs the build to be working).

推荐答案

是的,这是可能的.但是,这意味着您必须在执行 任务之前解析和检索 jar.有两种方法可以做到这一点:

Yes, it is possible. However, it means that you must resolve and retrieve the jars before that <taskdef> task is executed. There are two ways to do this:

  • 任务放在 之前代码>任务.所有三个都可以在 之外.但是,在这种情况下,如果您运行 clean,这三个任务将在 clean 之前首先执行,这意味着一个简单的 clean 将需要更长的时间,你必须确保你没有 clean 期间做的任何事情代码>.

  • Put the <ivy:resolve> and a <ivy:retrieve> task before the <typedef/> task. All three can be outside of a <target>. However, in that case, if you run a clean, these three tasks will be executed first before the clean which means a simple clean will take longer, and you have to make sure you don't clean anything done during the <ivy:resolve> and the <ivy:retrieve>.

将所有三个放在自己的目标中,然后使依赖于该第三方 jar 的目标依赖于检索 Ivy jar 并定义任务的目标.这对于几乎所有任务都使用的 Ant-Contrib 任务来说可能很困难,但对于诸如在构建过程最后使用的某种打包任务之类的任务应该会更容易.

Put all three in their own target, then make the target which is dependent upon that third party jar dependent upon the target that retrieves the Ivy jars and defines the task. This can be difficult with something like the Ant-Contrib tasks which may be used by almost all of the tasks, but should be easier with things like some sort of packaging task that's used at the very end of your build process.

这篇关于如何使用依赖于 ivy 导入的 lib 的 Ant taskdef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆