peterreilly 2004/09/17 05:53:48 Modified: docs/manual/OptionalTasks script.html Log: add in ruby examples and another groovy example example from Cedric Beust's blog http://beust.com/weblog/archives/000181.html with a conversion to groovy from Sam Pullara Revision Changes Path 1.19 +32 -3 ant/docs/manual/OptionalTasks/script.html Index: script.html =================================================================== RCS file: /home/cvs/ant/docs/manual/OptionalTasks/script.html,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- script.html 15 Sep 2004 14:19:38 -0000 1.18 +++ script.html 17 Sep 2004 12:53:48 -0000 1.19 @@ -1,7 +1,7 @@ <html> <head> -<meta http-equiv="Content-Language" content="en-us"> +<meta http-equiv="Content-Language" content="en-us"></meta> <title>Script Task</title> </head> @@ -19,7 +19,7 @@ valid Java identifiers, that is). The name "project" is a pre-defined reference to the Project, which can be used instead of the project name. The name "self" is a pre-defined reference to the actual -<script>-Task instance.<br>From these objects you have access to the Ant Java API, see the +<script>-Task instance.<br/>From these objects you have access to the Ant Java API, see the <a href="../api/index.html">JavaDoc</a> (especially for <a href="../api/org/apache/tools/ant/Project.html">Project</a> and <a href="../api/org/apache/tools/ant/taskdefs/optional/Script.html">Script</a>) for more information.</p> @@ -55,7 +55,7 @@ </tr> </table> <h3>Examples</h3> -The following snippet shows use of four different languages: +The following snippet shows use of five different languages: <blockquote><pre> <property name="message" value="Hello world"/> @@ -71,6 +71,10 @@ println 'message is ', message </script> + <script language="ruby"> + print 'message is ', $message, "\n" + </script> + <script language="jython"> print "message is %s" % message </script> @@ -80,6 +84,31 @@ Note that for the <i>jython</i> example, the script contents <b>must</b> start on the first column. </p> + <p> + The following script shows a little more complicted jruby example: + </p> + <blockquote><pre> +<script language="ruby"> + xmlfiles = Dir.new(".").entries.delete_if { |i| ! (i =~ /\.xml$/) } + xmlfiles.sort.each { |i| $self.log(i) } +</script> +</pre> + </blockquote> + <p> + Note that due to a limitation in the current version of jruby (0.7.0), + $project.log("Hello World") does not work (most likely because there are + two log methods on Project), this is fixed in the current CVS version of jruby. + </p> + <p> + The same example in groovy is: + </p> + <blockquote><pre> +<script language="groovy"> + xmlfiles = new java.io.File(".").listFiles().findAll{ it =~ "\.xml$"} + xmlfiles.sort().each { self.log(it.toString())} +</script> +</pre> + </blockquote> <p> The following script uses javascript to create a number of echo tasks and execute them.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]