Well, with a +1000000, I couldn't resist making the change I proposed. :)
Attached is a patch against the ANT_14 versions of Script.java and the
documentation file for this task.
Here is the sample build file that I used to test my change with:
<project default="test">
<target name="test">
<script language="javascript"> <![CDATA[
echo = project.createTask("echo");
main.addTask(echo);
for (i=1; i<=10; i++) {
echo.setMessage(i*i);
echo.execute();
}
]]> </script>
</target>
<target name="main"/>
</project>
----- Original Message -----
From: "Peter Donald" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, September 27, 2001 5:01 PM
Subject: Re: Javascript errors
> On Fri, 28 Sep 2001 05:06, Erik Hatcher wrote:
> > This problem actually could be alleviated with a patch to the <script>
task
> > such that the project reference was fed to BSF with the name "project"
> > rather than as the name of the project. I've got a few such similar
> > patches on my to-do list for the <script> task to make using it easier.
I
> > won't have time to get to this patch very soon though, but it appears to
be
> > a straightforward change.
>
> +1000000 ;)
>
> --
> Cheers,
>
> Pete
>
> When a stupid man is doing something he's ashamed of, he always
> declares that it is his duty.
> George Bernard Shaw
>
Index: src/main/org/apache/tools/ant/taskdefs/optional/Script.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Script.java,v
retrieving revision 1.5
diff -u -r1.5 Script.java
--- src/main/org/apache/tools/ant/taskdefs/optional/Script.java 2001/01/03
14:18:35 1.5
+++ src/main/org/apache/tools/ant/taskdefs/optional/Script.java 2001/09/28
03:47:04
@@ -97,6 +97,8 @@
addBeans(project.getTargets());
addBeans(project.getReferences());
+ beans.put("project", getProject());
+
BSFManager manager = new BSFManager ();
for (Enumeration e = beans.keys() ; e.hasMoreElements() ;) {
Index: docs/manual/OptionalTasks/script.html
===================================================================
RCS file: /home/cvspublic/jakarta-ant/docs/manual/OptionalTasks/script.html,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 script.html
--- docs/manual/OptionalTasks/script.html 2001/08/28 21:50:54 1.2.2.1
+++ docs/manual/OptionalTasks/script.html 2001/09/28 03:47:04
@@ -15,7 +15,7 @@
See <a href="../install.html#librarydependencies">Library Dependencies</a> for
more information.</p>
<p>All items (tasks, targets, etc) of the running project are
accessible from the script, using either their <code>name</code> or
-<code>id</code> attributes.</p>
+<code>id</code> attributes. The name "project" is a pre-defined reference to
the Project, which can be used instead of the project name.</p>
<p>Scripts can do almost anything a task written in Java could do.</p>
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">