I actually do something similar

1. I declare some properties such as
- action.build
- action.clean
- action.test

2. I declare some targets to set the properties, such as
<target build> -> action.build = true
<target clean> ->action.clean = true
<target test> -> action.test = true


3. In my sub build files I check the action on each target <target SubSystem1> <if action.clean> ->clean it <if action.build> ->build it <if action.test> ->test it </target>

this allows me to do things like
nant clean buid test SubSystem1 SubSystem2
nant test SubSystem1
nant build SubSystem2

etc...



4. I also have a bunch of tasks that maintain the build order dependancies...


This approach lets me keep my build files small and implement specific behaviour for each action that I want.

brant


From: "Giuseppe Greco" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [nant-dev] Current target again...
Date: Tue, 2 Mar 2004 07:49:11 +0100 (CET)

Hi all,

In my previous email there was a copy-and-paste
problem, and my explanation was incomplete!

I'll try again...

I use to structure projects like this:

/myProject
    + default.build
    + /src
        + default.build
        + /subproject1
        |       + default.build
        |       + mySource.cs
        + /subproject2
                + default.build
                + mySource.cs

This structure let me build subprojects from any
level. The build file located in the /src directory
is just a gateway build file, and looks like this:

<?xml version="1.0"?>

<project
  name="myProject"
  default="recurse">

  <target
    name="recurse"
    description="Builds recursively all subprojects">
    <foreach
      item="Folder"
      property="foldername">
      <in>
        <items>
          <includes name="*"/>
          <excludes name="CVS"/>
        </items>
      </in>
      <do>
        <nant
          buildfile="${foldername}/default.build"
          target="${project.config} ${target}"/>
      </do>
    </foreach>
  </target>

</project>

The 'target' property of the <nant> task specifies
two targets: ${project.config} and ${target}. Both
are inherited from the calling build file (the one
located in the project's root directory).

${project.config} contains 'release' or 'debug', while
${target} contains the target that should be executed
in each subproject.

My proposal is to introduce the concept of "generic target".
Let's go back to our gateway build file described above,
and rewrite the <recurse> target as a generic target:

<?xml version="1.0"?>

<project
  name="myProject"
  default="*">

  <target
    name="*"
    description="Builds recursively all subprojects">
    <foreach
      item="Folder"
      property="foldername">
      <in>
        <items>
          <includes name="*"/>
          <excludes name="CVS"/>
        </items>
      </in>
      <do>
        <nant
          buildfile="${foldername}/default.build"
          target="${project.config} ${nant.current.target}"/>
      </do>
    </foreach>
  </target>

</project>

Generic targets would specify "*" as their name, and NAnt
would always execute them. At that point we also need a way
to get the target name specified by the calling build file,
and the answer is a built-in property named ${nant.current.target}.

What's your opinion?

j3d.

----------------------------------------
Giuseppe Greco

::agamura::

phone:  +41 (0)91 604 67 65
mobile: +41 (0)76 390 60 32
email:  [EMAIL PROTECTED]
web:    www.agamura.com
----------------------------------------


------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ nant-developers mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/nant-developers

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to