ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peter.rei...@corvil.com>
Subject [Patch] Support for the groovy language with the ant <script> task
Date Tue, 03 Feb 2004 13:58:59 GMT
Hi,

I have been looking at the groovy language:
http://groovy.codehaus.org/
and the <script> task.

The included patch will allow groovy to
be one of the supported languages for <script> allowing
the following:

    <script language="groovy"><![CDATA[
      z = <<<END
      this is a multi
      line string
END

      println(z);
      list = [1, 2, 3]
      println(list[0..2])
      map=["a":1, "b":2]
      println("a is " + map["a"])

    ]]></script>

printing out:

Declaring bean: g3 value: g3
Declaring bean: s2 value: s2
Declaring bean: self value: org.apache.tools.ant.taskdefs.optional.Script@11d0a4f
Declaring bean: s5 value: s5
Declaring bean: project value: org.apache.tools.ant.Project@18fd984
Declaring bean: s4 value: s4
Declaring bean: b3 value: b3
Declaring bean: g value: g
Declaring bean: s3 value: s3
Declaring bean: b value: b
Declaring bean: basedir value: /home/preilly/learning/ant
Declaring bean: s value: s
      this is a multi
      line string
[1, 2, 3]
a is 1

(The "Declaring bean" prints are due to a printf  in groovy - 1.0.beta-3). (org.codehaus.groovy.bsf.GroovyEngine)

The patch are two changes:

   Script.java :       the Groovy language does not like "<ANT>" to be the name of the
script
                       changed to "ANT" (For some reason it attempts to make a class? for
the name).

   ScriptDef.java:     Changed from "script <name>" to "script_name"
 

   ScriptRunner.java : add groovy to the BSF supported languages (in the same way that beanshell
used
                                   to be added to BSF).

  
I would like to make the changes to ANT CVS and possiblely to the ant 1.6 branch.

Peter



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message