Diane, That's exactly what I wound up doing, actually. I used a property of a comma separated list, and wrote some javascript to parse it into a list. Seems to work just fine. It's nice to get some verification that this is a reasonable way to do it.
Thanks, Rob Seeger At 08:50 AM 10/25/01 -0700, you wrote: >--- Robert Seeger <[EMAIL PROTECTED]> wrote: >> - How can I define a "list of items" in ant? >> I want to be able to say something like >> <this-package-depends-on-the-following-packages name="pkgdepends"> >> <item>PkgDatabase</item> >> <item>PkgLogger</item> >> <item>PkgFtp</item> >> </this...package> > >I think to do that you'd need to create a new type (eg., <list>) and then ><typedef> it -- but I've not really looked into doing that sort of thing, >so I can't really tell you much about how to do it. > >The best I can offer at this point is to suggest you make your >"pkgdepends" a property, and just put the values into it as either a >space- or comma-separated list. > >> - How can I iterate over that list in javascript? >> I want to be able to do the following type of thing in javascript... >> classpath=""; >> prefix="/usr/lib"; >> suffix="src/java"; >> foreach pkg ${pkgdepends} { >> if(classpath == "") { >> classpath = "$prefix/$pkg/$suffix"; >> } else { >> classpath = "$classpath:$prefix/$pkg/$suffix"; >> } >> } >> project.setProperty("pkg.classpath", $classpath); > ><property name="pkgdepends" value="PkgDatabase,PkgLogger,PkgFTP"/> >or ><property name="pkgdepends" value="PkgDatabase PkgLogger PkgFTP"/> >or ><property name="pkgdepends" value="PkgDatabase, PkgLogger, PkgFTP"/> >or >$ ant -Dpkgdepends="foo, bar, blat" setPkgCP #you get the idea :) > ><target name="setPkgCP"> > <property name="prefix" value="/usr/lib/"/> > <property name="suffix" value="/src/java"/> > <script language="javascript"> <![CDATA[ > importClass(java.util.StringTokenizer); > prefix = projname.getProperty("prefix"); > suffix = projname.getProperty("suffix"); > pkgs = new StringTokenizer(projname.getProperty("pkgdepends"), " ,"); > sep = projname.getProperty("path.separator"); > cp = ""; > while (pkgs.hasMoreTokens()) { > pkg = pkgs.nextToken(); > if(cp){ > cp = cp + sep + prefix + pkg + suffix; > } > else{ > cp = prefix + pkg + suffix; > } > } > projname.setProperty("pkg.classpath", cp); > ]]> </script> > <echo message="${pkg.classpath}"/> ></target> > >Note: Replace "projname" with the actual name of your project. Also, if >you don't need to allow "prefix" and "suffix" to be overridden, you don't >really need to set them as properties -- just set them as vars in the >script directly. > >Diane > >===== >([EMAIL PROTECTED]) > > > >__________________________________________________ >Do You Yahoo!? >Make a great connection at Yahoo! Personals. >http://personals.yahoo.com > ======================================== Robert Seeger Network Engineer Nortel Networks Telephone: (518)237-2087 Pager: (800)SKY-8888 Pin#1264792 Fax: (518)237-4190 Email: [EMAIL PROTECTED] Address: 224 5th Ave, Apt#2 Lansingburgh, NY 12182 ========================================