----- Original Message -----
From: "Jose Alberto Fernandez" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 23, 2000 10:44 PM
Subject: RE: Javaworld Article about Ant


> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> >
> > At 12:45 PM -0700 10/23/00, Jose  Alberto Fernandez wrote:
> > >The funny thing is the article subtitle is:
> > >"Introducing the powerful XML-based scripting tool, Ant"
> > >and we keep on fighting that ANT is not a scripting language...
> >
> > Oh, but to be honest, it really is, in XML clothing. Now, we just
> > need a way to define tasks within ANT itself... With BSF, that should
> > be quite doable.
> >
>
> Yes, I have some ideas on how to do this, but I have not had the time to
> try them out. I think that is the main missing feature in the ANT <->
> <script>
> connection. How good is scripting if I cannot define new tasks with it.
>

What about:

<?xml version="1.0" encoding="utf-8"?>
<project name="myProject" default="default" basedir=".">

  <taskdef name="function"
classname="org.apache.tools.ant.taskdefs.optional.Function"/>

  <target name="init">
    <function name="printArg1">
      <script language="javascript"> <![CDATA[
        myProject.log('arg1: ' + arg1);
      ]]></script>
    </function>
  </target>

  <target name="default" depends="init">
    <printArg1>
      <param name="arg1" value="value of arg1"/>
    </printArg1>

    <echo message="arg1: ${arg1}"/>
  </target>
</project>


It's a quick hack for now and can not do any error-checking regarding
reqquired arguments and so on, but it works :-)

Task included. I may improve it further, but don't know when. If you find
some time to improve it feel free to do so :-)

Nico

Attachment: Function.java
Description: Binary data

Reply via email to