Browse Source

add some more doc for the scripting changes

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@486341 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
9bead93cc5
5 changed files with 175 additions and 10 deletions
  1. +4
    -1
      docs/manual/CoreTasks/conditions.html
  2. +35
    -2
      docs/manual/CoreTypes/filterchain.html
  3. +36
    -1
      docs/manual/CoreTypes/mapper.html
  4. +37
    -1
      docs/manual/CoreTypes/selectors.html
  5. +63
    -5
      docs/manual/OptionalTasks/scriptdef.html

+ 4
- 1
docs/manual/CoreTasks/conditions.html View File

@@ -469,7 +469,10 @@ tasks, datatypes, scriptdefs, macrodefs and presetdefs.</p>


<p>Evaluate a condition based on a script in any <p>Evaluate a condition based on a script in any
<a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a> <a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a>
supported language.</p>
or
<a href="https://scripting.dev.java.net">JSR 223</a>
supported language.
</p>
<p> <p>
See the <a href="../OptionalTasks/script.html">Script</a> task for See the <a href="../OptionalTasks/script.html">Script</a> task for
an explanation of scripts and dependencies. an explanation of scripts and dependencies.


+ 35
- 2
docs/manual/CoreTypes/filterchain.html View File

@@ -1356,6 +1356,8 @@ Delete tabs from lines, trim the lines and removes empty lines.
<p><b><em><a name="scriptfilter">ScriptFilter</a></em></b></p> <p><b><em><a name="scriptfilter">ScriptFilter</a></em></b></p>
This is an optional filter that executes a script in a This is an optional filter that executes a script in a
<a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a> <a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a>
or
<a href="https://scripting.dev.java.net">JSR 223</a>
supported language.</p> supported language.</p>
See the <a href="../OptionalTasks/script.html">Script</a> task for See the <a href="../OptionalTasks/script.html">Script</a> task for
an explanation of scripts and dependencies. an explanation of scripts and dependencies.
@@ -1377,9 +1379,18 @@ This filter may be used directly within a filterchain.<p>
<tr> <tr>
<td vAlign=top>language</td> <td vAlign=top>language</td>
<td vAlign=top> The programming language the script is written in. <td vAlign=top> The programming language the script is written in.
Must be a supported Apache BSF language</td>
Must be a supported Apache BSF or JSR 223 language</td>
<td vAlign=top align="center">Yes</td> <td vAlign=top align="center">Yes</td>
</tr> </tr>
<tr>
<td valign="top">manager</td>
<td valign="top">
The script engine manager to use.
See the <a href="../OptionalTasks/script.html">script</a> task
for using this attribute.
</td>
<td valign="top" align="center">No - default is "auto"</td>
</tr>
<tr> <tr>
<td vAlign=top>src</td> <td vAlign=top>src</td>
<td vAlign=top>The location of the script as a file, if not inline <td vAlign=top>The location of the script as a file, if not inline
@@ -1387,8 +1398,30 @@ Must be a supported Apache BSF language</td>
<td vAlign=top align="center">No</td> <td vAlign=top align="center">No</td>
</tr> </tr>
<tr> <tr>
<td valign="top">setbeans</td>
<td valign="top">whether to have all properties, references and targets as
global variables in the script.</td>
<td valign="top" align="center">No, default is "true".</td>
</tr>
<tr>
<td valign="top">classpath</td>
<td valign="top">
The classpath to pass into the script.
</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">classpathref</td>
<td valign="top">The classpath to use, given as a
<a href="../using.html#references">reference</a> to a path defined elsewhere.
<td align="center" valign="top">No</td>
</tr>
</table> </table>

<p>
This filter can take a nested &lt;classpath&gt; element.
See the <a href="../OptionalTasks/script.html">script</a> task
on how to use this element.
</p>
<h4>Examples:</h4> <h4>Examples:</h4>


Convert to uppercase: Convert to uppercase:


+ 36
- 1
docs/manual/CoreTypes/mapper.html View File

@@ -707,6 +707,8 @@ with <code>&lt;uptodate&gt;</code> and <code>&lt;junit&gt;</code> output.</p>
<h4><a name="script-mapper">scriptmapper (since Ant 1.7)</a></h4> <h4><a name="script-mapper">scriptmapper (since Ant 1.7)</a></h4>
<p> <p>
This mapper executes a script written in <a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a> This mapper executes a script written in <a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a>
or
<a href="https://scripting.dev.java.net">JSR 223</a>
supported language, once per file to map.</p> supported language, once per file to map.</p>
The script can be declared inline or in a specified file. The script can be declared inline or in a specified file.
</p> </p>
@@ -728,6 +730,15 @@ an explanation of scripts and dependencies.
</td> </td>
<td align="center" valign="top">Yes</td> <td align="center" valign="top">Yes</td>
</tr> </tr>
<tr>
<td valign="top">manager</td>
<td valign="top">
The script engine manager to use.
See the <a href="../OptionalTasks/script.html">script</a> task
for using this attribute.
</td>
<td valign="top" align="center">No - default is "auto"</td>
</tr>
<tr> <tr>
<td valign="top">src</td> <td valign="top">src</td>
<td valign="top"> <td valign="top">
@@ -735,10 +746,34 @@ an explanation of scripts and dependencies.
</td> </td>
<td align="center" valign="top">No</td> <td align="center" valign="top">No</td>
</tr> </tr>
<tr>
<td valign="top">setbeans</td>
<td valign="top">whether to have all properties, references and targets as
global variables in the script.</td>
<td valign="top" align="center">No, default is "true".</td>
</tr>
<tr>
<td valign="top">classpath</td>
<td valign="top">
The classpath to pass into the script.
</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">classpathref</td>
<td valign="top">The classpath to use, given as a
<a href="../using.html#references">reference</a> to a path defined elsewhere.
<td align="center" valign="top">No</td>
</tr>
</table> </table>
<p>
This filename mapper can take a nested &lt;classpath&gt; element.
See the <a href="../OptionalTasks/script.html">script</a> task
on how to use this element.
</p>


<p> <p>
Example
<b>Example:</b>
</p> </p>
<blockquote><pre> <blockquote><pre>
&lt;scriptmapper language="javascript"&gt; &lt;scriptmapper language="javascript"&gt;


+ 37
- 1
docs/manual/CoreTypes/selectors.html View File

@@ -87,7 +87,8 @@
they are signed, and optionally if they have a signature of a certain name. they are signed, and optionally if they have a signature of a certain name.
</li> </li>
<li><a href="#scriptselector"><code>&lt;scriptselector&gt;</code></a> - <li><a href="#scriptselector"><code>&lt;scriptselector&gt;</code></a> -
Use a BSF scripting language to create your own selector
Use a BSF or JSR 223 scripting language to create
your own selector
</li> </li>
</ul> </ul>


@@ -976,6 +977,8 @@
The <code>&lt;scriptselector&gt;</code> element enables you The <code>&lt;scriptselector&gt;</code> element enables you
to write a complex selection algorithm in any to write a complex selection algorithm in any
<a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a> <a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a>
or
<a href="https://scripting.dev.java.net">JSR 223</a>
supported language.</p> supported language.</p>
See the <a href="../OptionalTasks/script.html">Script</a> task for See the <a href="../OptionalTasks/script.html">Script</a> task for
an explanation of scripts and dependencies. an explanation of scripts and dependencies.
@@ -994,12 +997,45 @@
<td valign="top">language of the script.</td> <td valign="top">language of the script.</td>
<td valign="top" align="center">yes</td> <td valign="top" align="center">yes</td>
</tr> </tr>
<tr>
<td valign="top">manager</td>
<td valign="top">
The script engine manager to use.
See the <a href="../OptionalTasks/script.html">script</a> task
for using this attribute.
</td>
<td valign="top" align="center">No - default is "auto"</td>
</tr>
<tr> <tr>
<td valign="top">src</td> <td valign="top">src</td>
<td valign="top">filename of the script</td> <td valign="top">filename of the script</td>
<td valign="top" align="center">no</td> <td valign="top" align="center">no</td>
</tr> </tr>
<tr>
<td valign="top">setbeans</td>
<td valign="top">whether to have all properties, references and targets as
global variables in the script.</td>
<td valign="top" align="center">No, default is "true".</td>
</tr>
<tr>
<td valign="top">classpath</td>
<td valign="top">
The classpath to pass into the script.
</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">classpathref</td>
<td valign="top">The classpath to use, given as a
<a href="../using.html#references">reference</a> to a path defined elsewhere.
<td align="center" valign="top">No</td>
</tr>
</table> </table>
<p>
This selector can take a nested &lt;classpath&gt; element.
See the <a href="../OptionalTasks/script.html">script</a> task
on how to use this element.
</p>
<p> <p>
If no <code>src</code> attribute is supplied, the script must be nested If no <code>src</code> attribute is supplied, the script must be nested
inside the selector declaration. inside the selector declaration.


+ 63
- 5
docs/manual/OptionalTasks/scriptdef.html View File

@@ -28,7 +28,10 @@
<h3>Description</h3> <h3>Description</h3>
<p>Scriptdef can be used to define an Ant task using a scripting language. Ant <p>Scriptdef can be used to define an Ant task using a scripting language. Ant
scripting languages supported by scripting languages supported by
<a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a> may be
<a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a>
or
<a href="https://scripting.dev.java.net">JSR 223</a>
may be
used to define the script. Scriptdef provides a mechanism to encapsulate used to define the script. Scriptdef provides a mechanism to encapsulate
control logic from a build within an Ant task minimizing the need for control logic from a build within an Ant task minimizing the need for
providing control style tasks in Ant itself. Complex logic can be made providing control style tasks in Ant itself. Complex logic can be made
@@ -95,9 +98,18 @@ more information on writing scripts, please refer to the
<tr> <tr>
<td valign="top">language</td> <td valign="top">language</td>
<td valign="top">The programming language the script is written in. <td valign="top">The programming language the script is written in.
Must be a supported Apache BSF language</td>
Must be a supported Apache BSF or JSR 223 language</td>
<td valign="top" align="center">Yes</td> <td valign="top" align="center">Yes</td>
</tr> </tr>
<tr>
<td valign="top">manager</td>
<td valign="top">
The script engine manager to use.
See the <a href="../OptionalTasks/script.html">script</a> task
for using this attribute.
</td>
<td valign="top" align="center">No - default is "auto"</td>
</tr>
<tr> <tr>
<td valign="top">src</td> <td valign="top">src</td>
<td valign="top">The location of the script as a file, if not inline</td> <td valign="top">The location of the script as a file, if not inline</td>
@@ -110,7 +122,29 @@ more information on writing scripts, please refer to the
</td> </td>
<td valign="top" align="center">No</td> <td valign="top" align="center">No</td>
</tr> </tr>
</table>
<tr>
<td valign="top">classpath</td>
<td valign="top">
The classpath to pass into the script.
</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">classpathref</td>
<td valign="top">The classpath to use, given as a
<a href="../using.html#references">reference</a> to a path defined elsewhere.
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">loaderRef</td>
<td valign="top">the name of the loader that is
used to load the script, constructed from the specified
classpath. This allows multiple script defintions
to reuse the same class loader.
</td>
<td align="center" valign="top">No</td>
</tr>
</table>


<h3>Nested elements</h3> <h3>Nested elements</h3>
<h4>attribute</h4> <h4>attribute</h4>
@@ -158,7 +192,11 @@ more information on writing scripts, please refer to the
</tr> </tr>
</table> </table>



<h4>classpath</h4>
<p>
See the <a href="../OptionalTasks/script.html">script</a> task
for using this nested element.
</p>


<h3>Examples</h3> <h3>Examples</h3>


@@ -236,7 +274,7 @@ Script errors are only detected when a script task is actually executed.
</p> </p>


<pre> <pre>
&lt;target name="echo-task-jython"&gt;
&lt;target name="echo-task-jython"&gt;
&lt;scriptdef language="jython" &lt;scriptdef language="jython"
name="echo" name="echo"
uri="http://example.org/script"&gt; uri="http://example.org/script"&gt;
@@ -252,6 +290,26 @@ self.log("text: " +self.text)
&lt;/target&gt; &lt;/target&gt;
</pre> </pre>


The next example shows the use of &lt;classpath&gt; and
"loaderref" to get access to the beanshell jar.
<pre>
&lt;scriptdef name="b1" language="beanshell"
loaderref="beanshell-ref"&gt;
&lt;attribute name="a"/&gt;
&lt;classpath
path="${user.home}/scripting/beanshell/bsh-1.3b1.jar"/&gt;
self.log("attribute a is " + attributes.get("a"));
&lt;/scriptdef&gt;

&lt;scriptdef name="b2" language="beanshell"
loaderref="beanshell-ref"&gt;
&lt;attribute name="a2"/&gt;
self.log("attribute a2 is " + attributes.get("a2"));
&lt;/scriptdef&gt;

&lt;b1 a="this is an 'a'"/&gt;
&lt;b2 a2="this is an 'a2' for b2"/&gt;
</pre>
<h3>Testing Scripts</h3> <h3>Testing Scripts</h3>


<p> <p>


Loading…
Cancel
Save