From 9bead93cc5697dc7384ef93abd88f8239bf171b7 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Tue, 12 Dec 2006 21:47:56 +0000 Subject: [PATCH] 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 --- docs/manual/CoreTasks/conditions.html | 5 +- docs/manual/CoreTypes/filterchain.html | 37 ++++++++++++- docs/manual/CoreTypes/mapper.html | 37 ++++++++++++- docs/manual/CoreTypes/selectors.html | 38 ++++++++++++- docs/manual/OptionalTasks/scriptdef.html | 68 ++++++++++++++++++++++-- 5 files changed, 175 insertions(+), 10 deletions(-) diff --git a/docs/manual/CoreTasks/conditions.html b/docs/manual/CoreTasks/conditions.html index 9892d807b..111f79e97 100644 --- a/docs/manual/CoreTasks/conditions.html +++ b/docs/manual/CoreTasks/conditions.html @@ -469,7 +469,10 @@ tasks, datatypes, scriptdefs, macrodefs and presetdefs.

Evaluate a condition based on a script in any Apache BSF -supported language.

+ or + JSR 223 +supported language. +

See the Script task for an explanation of scripts and dependencies. diff --git a/docs/manual/CoreTypes/filterchain.html b/docs/manual/CoreTypes/filterchain.html index e2a99da22..29a86134e 100644 --- a/docs/manual/CoreTypes/filterchain.html +++ b/docs/manual/CoreTypes/filterchain.html @@ -1356,6 +1356,8 @@ Delete tabs from lines, trim the lines and removes empty lines.

ScriptFilter

This is an optional filter that executes a script in a Apache BSF + or + JSR 223 supported language.

See the Script task for an explanation of scripts and dependencies. @@ -1377,9 +1379,18 @@ This filter may be used directly within a filterchain.

language The programming language the script is written in. -Must be a supported Apache BSF language +Must be a supported Apache BSF or JSR 223 language Yes + + manager + + The script engine manager to use. + See the script task + for using this attribute. + + No - default is "auto" + src The location of the script as a file, if not inline @@ -1387,8 +1398,30 @@ Must be a supported Apache BSF language No + setbeans + whether to have all properties, references and targets as + global variables in the script. + No, default is "true". + + + classpath + + The classpath to pass into the script. + + No + + + classpathref + The classpath to use, given as a + reference to a path defined elsewhere. + No + - +

+ This filter can take a nested <classpath> element. + See the script task + on how to use this element. +

Examples:

Convert to uppercase: diff --git a/docs/manual/CoreTypes/mapper.html b/docs/manual/CoreTypes/mapper.html index b964f36cb..84078ed9b 100644 --- a/docs/manual/CoreTypes/mapper.html +++ b/docs/manual/CoreTypes/mapper.html @@ -707,6 +707,8 @@ with <uptodate> and <junit> output.

scriptmapper (since Ant 1.7)

This mapper executes a script written in Apache BSF +or + JSR 223 supported language, once per file to map.

The script can be declared inline or in a specified file.

@@ -728,6 +730,15 @@ an explanation of scripts and dependencies. Yes + + manager + + The script engine manager to use. + See the script task + for using this attribute. + + No - default is "auto" + src @@ -735,10 +746,34 @@ an explanation of scripts and dependencies. No + + setbeans + whether to have all properties, references and targets as + global variables in the script. + No, default is "true". + + + classpath + + The classpath to pass into the script. + + No + + + classpathref + The classpath to use, given as a + reference to a path defined elsewhere. + No + +

+ This filename mapper can take a nested <classpath> element. + See the script task + on how to use this element. +

-Example + Example:

 <scriptmapper language="javascript">
diff --git a/docs/manual/CoreTypes/selectors.html b/docs/manual/CoreTypes/selectors.html
index 70b7ab067..6d5a11744 100755
--- a/docs/manual/CoreTypes/selectors.html
+++ b/docs/manual/CoreTypes/selectors.html
@@ -87,7 +87,8 @@
         they are signed, and optionally if they have a signature of a certain name.
       
       
  • <scriptselector> - - Use a BSF scripting language to create your own selector + Use a BSF or JSR 223 scripting language to create + your own selector
  • @@ -976,6 +977,8 @@ The <scriptselector> element enables you to write a complex selection algorithm in any Apache BSF + or + JSR 223 supported language.

    See the Script task for an explanation of scripts and dependencies. @@ -994,12 +997,45 @@ language of the script. yes + + manager + + The script engine manager to use. + See the script task + for using this attribute. + + No - default is "auto" + src filename of the script no + + setbeans + whether to have all properties, references and targets as + global variables in the script. + No, default is "true". + + + classpath + + The classpath to pass into the script. + + No + + + classpathref + The classpath to use, given as a + reference to a path defined elsewhere. + No + +

    + This selector can take a nested <classpath> element. + See the script task + on how to use this element. +

    If no src attribute is supplied, the script must be nested inside the selector declaration. diff --git a/docs/manual/OptionalTasks/scriptdef.html b/docs/manual/OptionalTasks/scriptdef.html index 77ef56f37..58334fbf2 100755 --- a/docs/manual/OptionalTasks/scriptdef.html +++ b/docs/manual/OptionalTasks/scriptdef.html @@ -28,7 +28,10 @@

    Description

    Scriptdef can be used to define an Ant task using a scripting language. Ant scripting languages supported by -Apache BSF may be +Apache BSF +or + JSR 223 +may be used to define the script. Scriptdef provides a mechanism to encapsulate 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 @@ -95,9 +98,18 @@ more information on writing scripts, please refer to the language The programming language the script is written in. - Must be a supported Apache BSF language + Must be a supported Apache BSF or JSR 223 language Yes + + manager + + The script engine manager to use. + See the script task + for using this attribute. + + No - default is "auto" + src The location of the script as a file, if not inline @@ -110,7 +122,29 @@ more information on writing scripts, please refer to the No - + + classpath + + The classpath to pass into the script. + + No + + + classpathref + The classpath to use, given as a + reference to a path defined elsewhere. + No + + + loaderRef + 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. + + No + +

    Nested elements

    attribute

    @@ -158,7 +192,11 @@ more information on writing scripts, please refer to the - +

    classpath

    +

    + See the script task + for using this nested element. +

    Examples

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

    -    <target name="echo-task-jython">
    +<target name="echo-task-jython">
       <scriptdef language="jython"
           name="echo"
           uri="http://example.org/script">
    @@ -252,6 +290,26 @@ self.log("text: " +self.text)
     </target>
     
    +The next example shows the use of <classpath> and +"loaderref" to get access to the beanshell jar. +
    +    <scriptdef name="b1" language="beanshell"
    +               loaderref="beanshell-ref">
    +      <attribute name="a"/>
    +      <classpath
    +        path="${user.home}/scripting/beanshell/bsh-1.3b1.jar"/>
    +      self.log("attribute a is " + attributes.get("a"));
    +    </scriptdef>
    +
    +    <scriptdef name="b2" language="beanshell"
    +               loaderref="beanshell-ref">
    +      <attribute name="a2"/>
    +      self.log("attribute a2 is " + attributes.get("a2"));
    +    </scriptdef>
    +
    +    <b1 a="this is an 'a'"/>
    +    <b2 a2="this is an 'a2' for b2"/>
    +

    Testing Scripts