ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Surette <philsure...@home.com>
Subject Re: [PATCH] Script enhancement to standardize the "project" object exposed
Date Fri, 28 Sep 2001 08:13:54 GMT
What about adding in the target as well, e.g. something like:

             addBeans(project.getTargets());
             addBeans(project.getReferences());
 
             beans.put("project", getProject());

+            beans.put("target", getOwningTarget());
+
             BSFManager manager = new BSFManager ();
 
When I first started using the script tag a couple of weeks ago 
I just naturally expected to see both the target and the
project predefined in all scripts. They are the context for the
script. Having access to the grandparent (project) - while a 
_big_ improvement - without access to the parent (target) 
just seems wrong somehow.

(yes, you can get at the target if you know its name, but this
is just as inelegant as needing to know the project name: it creates
an easily broken dependency between the task name and the embedded
script and a real trap for all those cut-and-pasters out there)

Erik Hatcher wrote:
> 
> 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" <donaldp@apache.org>
> To: <ant-user@jakarta.apache.org>
> 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
> >
> 
>   ------------------------------------------------------------------------
>                     Name: patchfile.txt
>    patchfile.txt    Type: Plain Text (text/plain)
>                 Encoding: quoted-printable

Mime
View raw message