diff --git a/manual/Tasks/script.html b/manual/Tasks/script.html index 97482f923..2904f9ef9 100644 --- a/manual/Tasks/script.html +++ b/manual/Tasks/script.html @@ -228,6 +228,11 @@ of all files a <fileset/> caught.

// import statements // importPackage(java.io); importClass(java.io.File); + // Nashorn syntax + // load("nashorn:mozilla_compat.js"); + // or + // var File = Java.type('java.io.File'); + // Access to Ant-Properties by their names dir = project.getProperty("fs.dir"); @@ -268,13 +273,18 @@ so java.lang.System can be directly imported with importClass/importPackage. For other packages you have to prefix the full classified name with Packages. For example Ant's FileUtils class can be imported -with importClass(Packages.org.apache.tools.ant.util.FileUtils)
-The <script> task populates the Project instance under the -name project, so we can use that reference. Another way is to use its given name or -getting its reference from the task itself.
The Project provides methods for accessing and -setting properties, creating DataTypes and Tasks and much more.
After creating a FileSet object -we initialize that by calling its set-methods. Then we can use that object like a normal Ant task -(<copy> for example).
For getting the size of a file we instantiate +with importClass(Packages.org.apache.tools.ant.util.FileUtils)

+

In Java 8+, you may use the built-in Nashorn JavaScript engine rather than Rhino (which is +available in Java 7 runtime). Then, use Java.type as import statement for any Java +class +or the +compatibility script: load("nashorn:mozilla_compat.js");.

+

The <script> task populates the Project instance under the +name project, so we can use that reference. Another way is to use its +given name or getting its reference from the task itself. The Project provides methods for accessing +and setting properties, creating DataTypes and Tasks and much more.
After creating a FileSet +object we initialize that by calling its set-methods. Then we can use that object like a normal Ant +task (<copy> for example).
For getting the size of a file we instantiate a java.io.File. So we are using normal Java API here.
Finally we use the <echo> task for producing the output. The task is not executed by its execute() method, because the perform()