ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <>
Subject Re: Re[4]: Embedded dynamic ANT tasks.
Date Tue, 10 Jun 2003 09:06:32 GMT
This is mega cool.

I modified DynamicBSHTask#execute to use createDataType() rather
than createTask() and with ant 1.6 one can use the dynamic bsh
to define conditions, filters, and tasks very easily:

<project name="t">

  <taskdef name="bshdef"

  <taskdef resource="net/sf/antcontrib/"/>

  <target name="condition">
    <bshdef name="all.lower">
      /*% @implements %*/
      String message;

      void setString(String message) {
          global.message = message;

      boolean eval() {
          return (message.toLowerCase() == message);
      <all.lower string="this is lower"/>
        <echo>the string is all lower</echo>


  <target name="path">

    <bshdef name="showpath">
      /*% @extends %*/

      Path    path; createPath() {
          global.path = new Path(self.getProject());
          return global.path;

      void execute() {
         self.log("Path is " + global.path);
        <fileset dir="."/>


On Tuesday 10 June 2003 09:43, you wrote:
> Ah... yeah - this is tricky.... but possible:
> pr>    void execute() {      log("hello world");  }
> not  possible  because  once  you're inside the script, you are not anymore
> aware  that  you're  a  subclass  of some other method (BeanShell currently
> doesn't support this).
> pr>    void execute() {      this.log("hello world");  }
> Nope,   all  BeanShell scripts have a 'this' object which is of type XThis.
> Again:  beanshell  archtiecture,  which  is hard to modify (and it wouldn't
> make much sense anyway - Pat knows what he's doing :).
> pr>    void execute() {      global.log("hello world");  }
> global is for "instance" scope. This is misleading, but is explained in the
> BeanShell manual - in my application every script has its own namespace, so
> it is like class's instance scope.
> What  you  need  to  do  is  refer to methods of the 'self' object, which I
> register  for  every  script  as  a  public  global  variable.  This is the
> reference to your superclass.
> So: self.log("hello world"); should do the trick.
> check  out  the  examples (test cases) - there's some code that does access
> superclass methods and fields.

My bad, I should have looked harder.

> Unfortunately  you won't be able to access protected methods/ fields of the
> superclass - haven't figured out how to overcome this problem yet.
> Dawid

My direct e-mail gets bounced.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message