## Script

### Description

Execute a script in a BSF supported language.

All items (tasks, targets, etc) of the running project are accessible from the script, using either their `name` or `id` attributes.

Scripts can do almost anything a task written in Java could do.

### Parameters

Attribute | Description | Required
language | The programming language the script is written in. Must be a supported BSF language | No
src | The location of the script as a file, if not inline | No

### Examples

>     <project name="squares" default="main" basedir=".">

>       <target name="setup">

>         <script language="javascript"> <![CDATA[

>           for (i=1; i<=10; i++) {
>             echo = squares.createTask("echo");
>             main.addTask(echo);
>             echo.setMessage(i*i);
>           }

>         ]]> </script>

>       </target>

>       <target name="main" depends="setup"/>

>     </project>

generates

>     setup:

>     main:
>     1
>     4
>     9
>     16
>     25
>     36
>     49
>     64
>     81
>     100

>     BUILD SUCCESSFUL

Another example, using references by id and two different scripting languages:

>     <project name="testscript" default="main">
>       <target name="sub">
>         <echo id="theEcho"/>
>       </target>

>       <target name="sub1">
>         <script language="netrexx"><![CDATA[
>           theEcho.setMessage("In sub1")
>           sub.execute
>         ]]></script>
>       </target>

>       <target name="sub2">
>         <script language="javascript"><![CDATA[
>           theEcho.setMessage("In sub2");
>           sub.execute();
>         ]]></script>
>       </target>

>       <target name="main" depends="sub1,sub2"/>
>     </project>

generates

>     sub1:
>     In sub1

>     sub2:
>     In sub2

>     main:

>     BUILD SUCCESSFUL

Copyright © 2000,2001 Apache Software Foundation. All rights Reserved.