ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nico Seessle" <Nico.Sees...@epost.de>
Subject Re: Javaworld Article about Ant
Date Tue, 24 Oct 2000 00:12:16 GMT
----- Original Message -----
From: "Jose Alberto Fernandez" <JFernandez@viquity.com>
To: <ant-dev@jakarta.apache.org>
Sent: Monday, October 23, 2000 10:44 PM
Subject: RE: Javaworld Article about Ant


> > From: beard@netscape.com [mailto:beard@netscape.com]
> >
> > 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


Mime
View raw message