从父 build.xml 中调用依赖目标包含 xml [英] Calling depends targets from parent build.xml inside includes xml

查看:30
本文介绍了从父 build.xml 中调用依赖目标包含 xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为 build.xml 中包含"的一部分的 xml 文件是否可能依赖于该 build.xml 中的目标(向后依赖)?或者我是否需要创建一个仅包含前向依赖项的链,并且在 includesFile.target 上有依赖"?如果可能,我该如何称呼这些父目标?

Is it possible for xml files that are part of 'includes' inside build.xml to have depends on targets from that build.xml (backwards dependency)? Or do I need to create a chain of only forward dependencies, and having "depends" on includedFile.target down? If this is possible, how do I call these parent targets?

我试图在一个很长的 build.xml 文件之外提取几个目标,在这样的情况下:

I am trying to extract several targets outside of a very long build.xml file, in a situation like this:

build.xml 定义了一个非常常见的目标,buildMe 在整个 build.xml 文件中使用.它还定义了一个目标 runTasks.它包括 someTasks.xml.runTasks 依赖于 buildMe 和 someTasks.groupOfTasks.

build.xml defines a very common target, buildMe used throughout the build.xml file. It also defines a target runTasks. It includes someTasks.xml. runTasks depends on buildMe and someTasks.groupOfTasks.

someTasks.xml 定义目标 groupOfTasks、task0、task1、task2.groupOfTasks 依赖于 task0、task1 和 task2.现在 task0 task1 或 task2 可以依赖 build.xml 中的 buildMe 或 build.xml 中定义的其他一些目标吗?

someTasks.xml define targets groupOfTasks, task0, task1, task2. groupOfTasks depends on task0, task1 and task2. Now can task0 task1 or task2 depend on buildMe from build.xml, or some other target defined in build.xml?

推荐答案

这对我有用:在主项目文件中,目标默认值依赖于 commontasks.xml 中的目标,后者依赖于目标来自主项目文件:

This works for me: In the main project file the target default depends on a target from commontasks.xml which depends on a target from the main project file:

<project name="main" default="default">

  <import file="commontasks.xml" as="common" />

  <target name="default" depends="common.hello" description="the main project">
  </target>

  <target name="initMain">
    <echo>initializing main</echo>
    <property name="aValue" value="MAIN" />
  </target>

<project name="commontasks" >

  <target name="hello" depends="initMain">
    <echo>hello from common tasks</echo>
    <echo>aValue: ${aValue}</echo>
  </target>

当我运行 ant build 时,我得到:

When I run the ant build, I get:

initMain:
 [echo] initializing main
common.hello:
 [echo] hello from common tasks
 [echo] aValue: MAIN
default:
BUILD SUCCESSFUL

依赖是目标 default 依赖于 hello 依赖于 initMain 并且 hello 可以使用 hello 中定义的属性代码>initMain.

The dependency is target default depends on hello depends on initMain and hello can use properties defined in initMain.

这篇关于从父 build.xml 中调用依赖目标包含 xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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