2011-04-20 87 views
1

我正在嘗試使用NANT構建項目(A)。該項目(A)依賴於另一個項目(B),該項目也是由NANT構建的。我希望能夠從項目(A)的構建中調用依賴項目(B)的構建。我已經嘗試在項目A的構建文件中包含項目B的構建文件。這會產生一個錯誤,因爲這兩個構建文件包含共享相同名稱的目標。使用NANT構建子項目

有沒有一種方法來包含構建文件的別名?

回答

0

我正在嘗試使用include任務執行此操作,但發現該nant任務實際上是我所需要的。

3

你可以這樣做,通過創建一個「父」構建文件,使用「nant」動作來調用其他構建文件。

<target name="rebuild" depends="" > 
    <nant target="${target::get-current-target()}"> 
     <buildfiles> 
      <include name="projectB.build" /> 
      <include name="projectC.build" /> 
     </buildfiles> 
    </nant> 
</target> 
0

你可以在你的'主'文件中有幾個這樣的目標。我經常使用以下構造在目標之間共享一組構建文件,以便更輕鬆地進行腳本維護。

<fileset id="buildfiles.all"> 
    <include name="projectB.build"/> 
    <include name="projectB.build"/> 
</fileset> 

<target name="build"> 
    <nant target="${target::get-current-target()}"> 
     <buildfiles refid="buildfiles.all" /> 
    </nant> 
</target> 

<target name="clean"> 
    <nant target="${target::get-current-target()}"> 
     <buildfiles refid="buildfiles.all" /> 
    </nant> 
</target> 

<target name="publish"> 
    <nant target="${target::get-current-target()}"> 
     <buildfiles refid="buildfiles.all" /> 
    </nant> 
</target>