Hi,
I am a longtime ant user, and have started using Nant since I now have to do alot of .Net development. Nant is very useful, and one thing I should say about it compared to ant is that the source is a lot easier to understand.

I would never have had to post to this list, but since Nant is working so well for us I figured I would use it in kind of an embedded way to support an application that schedules and runs jobs on machines distributed over a LAN. I am defining my jobs as tasks in Nant, and executing the nant script by directly calling Project.run() and listening for build events. Whenever one of my custom tasks executes, I add it to a list of jobs in my listening application. This is the only way I have found to execute an arbitrary fragment of a Nant script and pass the data into my app. I am having some success, but I am hitting some obstacles and I wondered if I could ask for help or advice.

I need to be able to define so-called JobGroups that may contain either other JobGroups or Jobs. Below is a sample job definition script:

<project>
<JobGroup name="outer">
   <job exeName="5" machine="gig2b"/>
   <JobGroup name="inner">
       <job exeName="6" machine="gig2b"/>
   </JobGroup>
   <JobGroup name="inner2">
       <job exeName="7" machine="gig2b"/>
   </JobGroup>
</JobGroup>
</project>

Eventually, I want JobGroup and Job tasks to do something meaningful in their executeTask methods, but for the moment I am happy merely to have them composed into an object graph as described above, with all the benefits of executing in the Nant scripting environment - dynamic properties, functions, etc.

In my scheme, JobGroups are TaskContainers, and Jobs are Tasks. As you can see above, JobGroups need to be nestable to arbitrary depth. Jobs do not, they do not contain anything except it might be nice at some point to be able to nest dataypes like <args> inside them, but first things first -- I am just trying to get the skeleton code to work.

My problem is that my scripts run through, and my listener app registers each Group when it executes. Any Jobs that are nested in JobGroup tags are correctly added to the appropriate JobCollection property of the parent JobGroup, but JobGroups never contain their sub-groups. I don't understand why. Some code below should give an idea of how I am trying to implement this. Can anyone give me any advice on how to make this work in Nant?

class JobGroup : TaskContainer {

private JobDefinitionCollection _jobs;
private JobGroupCollection _groups;
[BuildElementArray("jobgroup")]
public JobGroupCollection groups
       {
           get { return _groups; }
           set
           {
               for( int i = 0; i < value.Count; i++ )
               {
                   JobGroup group = value[i];
                   this.addJobGroup( group );
               }
               this._groups = value;
           }
       }

[BuildElementArray("job")]
       public JobDefinitionCollection jobs
       {
           get { return _jobs; }
           set
           {
               String thisMethod = "jobs.set";
               log.Debug(thisMethod + ":entering...");
               for( int i = 0; i < value.Count; i++ )
               {
                   JobDefinition job = value[i];
                   this.addJobDefinition( job );
               }
               _jobs = value;
           }
       }
}




-------------------------------------------------------
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-developers mailing list
nant-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to