2011-04-20 72 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>