Ant 构建脚本、antcall、依赖等 [英] Ant build scripts, antcall, dependencies, etc

查看:47
本文介绍了Ant 构建脚本、antcall、依赖等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个构建脚本,作为该脚本的一部分,它会将一个 jar 文件复制到一个目录中,为了方便起见,我们将其称为 utils jar.utils jar 是由另一个目录中的另一个构建脚本构建的.我试图让我的构建脚本运行 utils 构建脚本,以便我可以确保 utils jar 是最新的.

I have a build script and as part of that script it copies a jar file to a directory, for ease lets call it the utils jar. the utils jar is built by another build script sitting in another directory. What im trying to do have my build script run the utils build script so that I can ensure the utils jar is up to date.

所以我知道我需要导入 utils 构建文件.

So I know I need to import the utils build file.

<import file="../utils/build/build.xml" />

这不起作用,因为导入任务与几乎所有其他 ant taks 不同,它不是从 basedir 运行的,而是从 pwd 运行的.所以为了解决这个问题,我有这个小曲子,它成功地导入了构建文件

Which doesn't work because the import task, unlike almost every other ant taks, doesn't run from basedir, it runs from the pwd. So to get around that I have this little ditty, which does successfully import the build file

  <property name="baseDirUpOne" location=".." />
  <import file="${baseDirUpOne}/utils/build/build.xml" />

既然我解决了我的导入问题,我需要调用任务,那应该很容易吧:

So now that ive solved my import problem I need to call the task, well that should be easy right:

<antcall target="utils.package" />

注意上面的utils是../utils/build/build.xml的项目名

我现在遇到的问题是 ant 调用不在 ../utils/build 中执行,所以我需要但找不到的是 runat 属性或类似的东西,本质上:

the problem I'm now running into is that ant call doesn't execute in ../utils/build so what I need, and cant find, is a runat property or something similar, essentially:

<antcall target="utils.package" runat="../utils/build" />

我需要这样做的原因是,在我的 utils 构建文件中,选择将哪些代码复制到 jar 的步骤是基于相对路径,以避免在我的 ant 文件中硬编码路径.有任何想法吗?

The reason I need this is that in my utils build file the step to select which code to copy to the jar is based on relative paths so as to avoid hardcoding paths in my ant file. Any ideas?

推荐答案

我有类似的设置:我有一个主要的 Ant build.xml,它调用一个单独的 build.xml,负责构建我的测试.我是这样做的:

I've got something similar set up: I have a main Ant build.xml which calls a separate build.xml that takes care of building my tests. This is how I do it:

<target name="build-tests">
    <subant target="build">
      <fileset dir="${test.home}" includes="build.xml"/>
    </subant>
</target>

诀窍是使用 subant 代替antcall.您不必导入其他构建文件.

The trick is to use subant instead of antcall. You don't have to import the other build file.

这篇关于Ant 构建脚本、antcall、依赖等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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