There seems a bug in <scriptdef> - it does not expand properties:

  <scriptdef name="test" language="jython">
    <attribute name="name"/>
#script
print ">>>>>> name='"+str(attributes.get('name'))+"'"
  </scriptdef>
  <property name="test" value="--test--"/>
  <test name="${test}"/>

prints 
>>>>>> name='${test}'

Do I need to do it manually?

- Alexey.

--
{ http://trelony.cjb.net/ } Alexey N. Solofnenko
Pleasant Hill, CA (GMT-8 usually)


-----Original Message-----
From: Conor MacNeill [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 09, 2003 6:58 AM
To: Ant Developers List
Subject: scriptdef

Hi all,

I've just added a <scriptdef> task to allow tasks to be created using
scripts. 
It's loosely based on something I wrote a while back for Mutant. 

Attached below is an example usage. I had to make a few small mods to the
core 
to give me enough control over the configuration of the task and its nested 
elements. The example should make usage pretty straight forward. Attributes 
and nested elements are passed in two script variables, oddly named 
"attributes" and "elements". The first of these is a simple map of Strings 
whilst the second is a map of lists.

One question I have is whether people feel this is something appropriate in 
Ant? Let me know your thoughts.

Formal documentation to follow ...

Conor


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

  <scriptdef name="scripttest" language="javascript">
    <attribute name="attr1"/>
    <element name="fileset" type="fileset"/>
    <element name="path" type="path"/>
    <![CDATA[
      
      project.log("Hello from script");
      project.log("Attribute attr1 = " + attributes.get("attr1"));
      project.log("First fileset basedir = "
        + elements.get("fileset").get(0).getDir(project));
      
    ]]>
  </scriptdef>
  
  <target name="test">
    <scripttest attr1="test">
      <path>
        <pathelement location="src"/>
      </path>
      <fileset dir="src"/>
      <fileset dir="main"/>
    </scripttest>
  </target>
</project>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to