Beth,

 

To iterate a FileSet, I think you will need to set the item in the <foreach>
task to File rather than String e.g.

 

    <foreach item="File" property="thirdPatry.name">

       <in>

           <items refid="thridPartyDirs" />

            Etc.

 

Also. if you want to check if the FileSet contains files, you can use the
fileset::to-string in NAntContrib.  E.g.

 

    <echo message="${fileset::to-string('thirdPartyDirs', ' | ')}">

 

will write a pipe delimited list of the files to the log/console

 

HTH,

Bill

  _____  

From: Beth Hechanova [mailto:bhechan...@imsco-us.com] 
Sent: 20 October 2009 19:32
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] using foreach to loop through strings

 

Hi,

 

I'm trying to make my build scripts a bit more maintainable.  Part of the
build script's job is to tag code into svn and export code from svn.  We
have a directory in svn called 'thirdParty' to hold our thirdParty libs.
The thirdParty directory holds thirdParty libs for many different
applications.

 

In my application build script, I am currently itemizing each individual
thirdParty folder in both the target that tags the source code and the
target that exports the source code.  If I add a new thirdParty dependency,
I have to remember to update the build script in both places.  

 

What I'd like to do is keep a "list" of thirdParty dependencies by my
application in a single place.  Then in both the tag and export targets
iterate over that list and build the appropriate command from the items in
that list.  I'm trying to use fileset and foreach tasks to accomplish this,
but so far I haven't been able to get it to work.

 

My fileset looks like (this is not contained in a target):

  <fileset id="thirdPartyDirs" >

    <include name="LLBLGenPro_v2.6" asis="true" />

    <include name="AjaxControlToolkit" asis="true" />

  </fileset>

 

And here's a portion of my target for exporting using the foreach task:

<target name="export.source.new" description="Gets the latest files from
Svn">

 

    <foreach item="String" property="thirdParty.name" >

      <in>

        <items refid="thirdPartyDirs" />

      </in>

      <do>

        <echo message="found ${thirdParty.name}"/>

        

        <exec program="svn">

          <arg value="export" />

          <arg value="--force" />

          <arg value="${export.source.root}/thirdParty/${thirdParty.name}"
/>

          <arg
value="${buildarea.application.thirdparty}/${thirdParty.name}" />

        </exec>

      </do>

    </foreach>

.

 

Something is not set up quite right as the message "found
${thirdParty.name}" never gets printed.

 

What am I missing?  Or, if there is a easier/better way to accomplish the
same thing using different tasks, please let me know.

I am using the latest nightly build: (Build 0.86.3412.0; nightly; 5/5/2009)

 

Thanks,

Beth

 

This email and any files transmitted with it are confidential & proprietary
to Systems and Software Enterprises, Inc. (dba IMS). This information is
intended solely for the use of the individual or entity to which it is
addressed. Access or transmittal of the information contained in this
e-mail, in full or in part, to any other organization or persons is not
authorized. 

 

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.421 / Virus Database: 270.14.22/2446 - Release Date: 10/19/09
14:33:00


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to