Search code examples
nant

Include/Exclude buildfiles


How do you do this? Given several build files, I only want to include the ones where the target (specified from the command line) exists. Using target::exists in does not seem to work. Thanks.

    <target name="*">
        <property name="curr.target" value="${target::get-current-target()}"/>

        <nant target="${curr.target}">
            <buildfiles>                    
                <include name="*.build" if="${target::exists(curr.target)}"/>
                <!-- avoid recursive execution of current build file-->
                <exclude name="${project::get-buildfile-path()}" />                    
            </buildfiles>                               
        </nant>
    </target>

Using robaker's solution, my final build file looks like this. It does not fail anymore if the target is not found in a certain build file (unlike my previous code).

<project>
   <include buildfile="A.build"/>
   <include buildfile="B.build"/>

   <target name="*">
      <nant target="${target::get-current-target()}"/>
   </target>
</project>

Solution

  • Why not just use the include task to include all your child build scripts instead?