This time with the attachment....
Peter
Peter Reilly wrote:
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:
[EMAIL PROTECTED]
Declaring bean: s5 value: s5
Declaring bean: project value: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Index: src/main/org/apache/tools/ant/taskdefs/optional/Script.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/Script.java,v
retrieving revision 1.25
diff -u -r1.25 Script.java
--- src/main/org/apache/tools/ant/taskdefs/optional/Script.java 23 Dec 2003 15:47:51 -0000 1.25
+++ src/main/org/apache/tools/ant/taskdefs/optional/Script.java 3 Feb 2004 13:57:43 -0000
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -95,7 +95,7 @@
runner.addBean("project", getProject());
runner.addBean("self", this);
- runner.executeScript("<ANT>");
+ runner.executeScript("ANT");
}
/**
Index: src/main/org/apache/tools/ant/util/ScriptRunner.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/ScriptRunner.java,v
retrieving revision 1.3
diff -u -r1.3 ScriptRunner.java
--- src/main/org/apache/tools/ant/util/ScriptRunner.java 27 Nov 2003 10:16:13 -0000 1.3
+++ src/main/org/apache/tools/ant/util/ScriptRunner.java 3 Feb 2004 13:57:43 -0000
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -70,6 +70,19 @@
* @author Conor MacNeill
*/
public class ScriptRunner {
+
+ // Register Groovy ourselves, since BSF does not
+ // natively support it (yet).
+ // This "hack" can be removed once BSF has been
+ // modified to support Groovy or more dynamic
+ // registration.
+ static {
+ BSFManager.registerScriptingEngine(
+ "groovy",
+ "org.codehaus.groovy.bsf.GroovyEngine",
+ new String[] {"groovy", "gy"});
+ }
+
/** Script language */
private String language;
Index: src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java,v
retrieving revision 1.7
diff -u -r1.7 ScriptDef.java
--- src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java 22 Sep 2003 08:58:58 -0000 1.7
+++ src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java 3 Feb 2004 13:57:43 -0000
@@ -351,7 +351,7 @@
runner.addBean("attributes", attributes);
runner.addBean("elements", elements);
runner.addBean("project", getProject());
- runner.executeScript("scriptdef <" + name + ">");
+ runner.executeScript("scriptdef_" + name);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]