2012-03-01 73 views
12

我有两个项目,每个项目都有自己的ant构建文件。依赖于另一个ant文件的ant文件

我应该怎么做,当我建立项目B时,它会首先使用项目A的antfile生成项目A?

+1

你找[这](https://ant.apache.org/manual/Tasks/ant.html)? – oers 2012-03-01 10:22:01

+0

啊,是的,我不知道这个任务类型,谢谢。 – 2012-03-01 11:19:21

+0

[Create a ant file to run other ant files]可能重复(http://stackoverflow.com/questions/6335971/create-an-ant-file-to-run-other-ant-files) – bytebuster 2015-08-04 01:59:48

回答

17

你可以通过使用ant task来实现这一点,它在外部构建文件上运行ant。

例子:

<ant antfile="../otherproject/build.xml" target="compile"/> 

属性
默认情况下,目前所有的属性都会被传递到被调用Ant构建,这可以通过设置inheritAll="false",如果你想在其他构建的行为本身禁用。

属性所需要的可以通过嵌套的标签进行传递:

<ant inheritAll="false" antfile="../otherproject/build.xml" target="compile"> 
    <property name="my.property" value="myValue"/> 
</ant> 
+2

我不得不添加另一个选项,以使其他任务在其自己的路径中工作: 2012-03-04 08:08:08

+0

@ErelSegalHalevi感谢您的反馈,我工作过进入答案 – oers 2012-03-05 07:13:47

+0

谢谢,这工作,但我看到很多'试图覆盖任务的旧定义...'警告。有任何解决这个问题的方法吗?谢谢。 – friederbluemle 2014-08-14 00:30:48