On 9/15/05, Bill Arnette <[EMAIL PROTECTED]> wrote:
> With my suggestion, 'nant -only:projectC' would only do the body of the
> projectC target and not execute the dependencies without cluttering the
> build file with dependency-only targets, or with if statements and unless
> attributes that short-circuit some of the tasks within a target.
> 
> </Bill>

Alternatively, with the previous suggestions, your projectC target
would become...
<target name="projectC"  depends="projectA, libY, libZ,
get-projectC-source, build-projectC" />
<target name="build-projectC">
    <exec program="devenv.com" commandline='projectC.vcproj /build
${build.config}'/>
</target>

Similarly, projectB would become...
<target name="projectB"  depends="get-projectB-source, libX, build-projectB"/>
<target name="build-projectB">
    <exec program="devenv.com" commandline='projectB.vcproj /build
${build.config}'/>
</target>

Do the build-projectB and build-projectC targets look similar?  We
could now refactor...
<target name="build-projectB">
  <property name="project.name" value="projectB.vcproj"/>
  <call target="build-project"/>
</target>
<target name="build-projectC">
  <property name="project.name" value="projectC.vcproj"/>
  <call target="build-project"/>
</target>
<target name="build-project">
    <exec program="devenv.com" commandline='${project.name} /build
${build.config}'/>
</target>

You may then have other projects that want to build based on vcproj
files, so you pull the build-project into a separate build file,
common-utils.build.xml.  Now your targets look something like...
<target name="build-projectB">
  <nant buildfile="common-utils.build.xml" target="build-project">
    <properties>
      <property name="project.name" value="projectB"/>
    </properties> 
  </nant>
</target>
<target name="build-projectC">
  <nant buildfile="common-utils.build.xml" target="build-project">
    <properties>
      <property name="project.name" value="projectC"/>
    </properties> 
  </nant>
</target>

Slightly more verbose than previous, but slightly safer use of
properties.  Even better if you found a task that compiled visual
studio projects, similar to the solution task - you would just stop
using the build-project target and your build file structure is
essentially unchanged.


To get to the point, "cluttering the build file with dependency-only
targets" improves the redundancy of the build file, allowing
separation of "doing" logic and "planning" logic.  You have a bunch of
targets which "do" stuff, which can be tested in isolation, then a
bunch of other targets which plan builds, updates, releases, or any
combination thereof.  Ideally, you'll find that your "doing" targets
become pretty common, and can be pulled into utility build files, or
replaced with tasks as they become available, and your major build
files contain almost completely planning targets, leveraging targets
that have already been tried and tested.

Give it a try, you might be surprised :-)

-- 
Troy


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to