2012-03-01 72 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