ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: Javascript to write MKDIR task ...
Date Tue, 25 Sep 2001 16:03:44 GMT
--- "Surtani, Manik" <Manik.Surtani@conchango.com> wrote:
> I have been looking at using javascript with the <script ...> tag to
> loop thru tasks, but can't seem to pass values to certain tasks:
> 
> E.g., I need to make a series of directories, and I do the following:
> 
>    <script language="javascript"> <![CDATA[
>       for (i=1; i<=10; i++) {
>         md = myProject.createTask("mkdir");
>         thisTarget.addTask(md);
>         md.setDir("/path/to/dir/dir_" + i);
>       }
>     ]]> </script>
> 
> .. And I get an error about setDir() not taking a String as a parameter.
> The ANT API says setDir() takes a File class, but how can I create a
> File class out of '"/path/to/dir/dir_" + I' in javascript?

  <target name="mkdirs">
    <script language="javascript"> <![CDATA[
      importClass(java.io.File);
      for (i=1; i<=10; i++) {
        md = myProject.createTask("mkdir");
        dir = new File("/path/to/dir/dir_" + i);
        md.setDir(dir);
        md.execute() ;
      }
      ]]>
    </script>
  </target>

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. http://im.yahoo.com

Mime
View raw message