You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by ru...@us.ibm.com on 2000/03/19 04:42:59 UTC

new *optional* scripting taskdef


OK, I've taken the plunge.  I've committed a scripting task to Ant.

If you like, think of it as a revolution.  It is in a separate
subdirectory, and it is not included in the bootstrap or included in the
Ant build by default.

Or, if you prefer, think of it as a first step towards moving the non-core
tasks out of the "minimalist" version of Ant.  Perhaps someday, we will
have two separate Jars.

In any case, below I've included a working script.  It doesn't do anything
useful, but it does give an indication of what is possible.

   <?xml version="1.0"?>

   <project name="test" default="main">

     <target name="main">
        <property name="welcome" value="from BSF!" />
        <echo message="hi there" id="echoTask"/>

        <script language="javascript">
           echoTask.setMessage(welcome)
           echoTask.execute()
        </script>
     </target>

   </project>

- Sam Ruby



Re: new *optional* scripting taskdef

Posted by "Kevin A. Burton" <bu...@relativity.yi.org>.
rubys@us.ibm.com wrote:
> 
> OK, I've taken the plunge.  I've committed a scripting task to Ant.
> 
> If you like, think of it as a revolution.  It is in a separate
> subdirectory, and it is not included in the bootstrap or included in the
> Ant build by default.
> 
> Or, if you prefer, think of it as a first step towards moving the non-core
> tasks out of the "minimalist" version of Ant.  Perhaps someday, we will
> have two separate Jars.
> 
> In any case, below I've included a working script.  It doesn't do anything
> useful, but it does give an indication of what is possible.
> 
>    <?xml version="1.0"?>
> 
>    <project name="test" default="main">
> 
>      <target name="main">
>         <property name="welcome" value="from BSF!" />
>         <echo message="hi there" id="echoTask"/>
> 
>         <script language="javascript">
>            echoTask.setMessage(welcome)
>            echoTask.execute()
>         </script>
>      </target>
> 
>    </project>
> 
> - Sam Ruby

Cool!  +1

I like it.  I would like to see something like this taken into more of a
global XML approach though.  Example.  XSLT if/for logic is stupid IMO. 
XSP/Cocoon 2.0 will probably fix this.  Though this would be too big an
optional task :)

Kevin

-- 
Kevin A Burton (burton@apache.org)
http://relativity.yi.org
Message to SUN:  "Please Open Source Java!"
"For evil to win is for good men to do nothing."

Re: new *optional* scripting taskdef

Posted by Will Uther <wi...@ai.mit.edu>.
Hi all,

--On Saturday, March 18, 2000 10:42 PM -0500 rubys@us.ibm.com wrote:

> OK, I've taken the plunge.  I've committed a scripting task to Ant.

  This looks very interesting :).  Just one quick question...  Why did you 
add extra 'id' attributes instead of using targets?  Targets are already 
named.

  My reason for asking is that it is unclear what your example script 
actually does:

>    <?xml version="1.0"?>
>
>    <project name="test" default="main">
>
>      <target name="main">
>         <property name="welcome" value="from BSF!" />
>         <echo message="hi there" id="echoTask"/>
>
>         <script language="javascript">
>            echoTask.setMessage(welcome)
>            echoTask.execute()
>         </script>
>      </target>
>
>    </project>

Does the echo task get run the first time time through the script?  My 
guess is yes.  This means the output would be:

hi there
from BSF!

In order to get a task referenced in a script that should not be executed 
normally you'd have to do something like:

>    <?xml version="1.0"?>
>
>    <project name="test" default="main">
>
>      <target name="neverrun">
>         <echo id="echoTask"/>
>      </target>
>
>      <target name="main">
>         <property name="welcome" value="hi there from BSF!" />
>
>         <script language="javascript">
>            echoTask.setMessage(welcome)
>            echoTask.execute()
>         </script>
>      </target>
>
>    </project>

which might output (haven't tested it):

hi there from BSF!

Which brings up another point:  it looks like ids are gloablly scoped. 
This is fine.  Just needs to be documented.

More interestingly, does this script work?  And what does it output?

>    <?xml version="1.0"?>
>
>    <project name="test" default="main">
>
>      <target name="main">
>         <property name="welcome" value="from BSF!" />
>
>         <script language="javascript">
>            echoTask.setMessage(welcome)
>            echoTask.execute()
>         </script>
>
>         <echo message="hi there" id="echoTask"/>
>      </target>
>
>    </project>

When I get back to CMU I'll have to play with this more...

later,

\x/ill        :-}