Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
Does scriptdef <element > use ant:current xmlns when defined in antlib?

Does scriptdef <element > use ant:current xmlns when defined in antlib?

2007-06-11       - By Vladimir Volod'ko
Reply:     1     2     3     4  

Hello!

I'm trying to put my script tasks in antlib and wonder why hte following code
does not work:

# complex/antlib.xml
<?xml version="1.0"?>
<antlib xmlns:cur="ant:current">

   <!-- Elementary task script -->
   <scriptdef name="elem" language="javascript" >
   <attribute name="name"/>
       <![CDATA[{
           self.log(attributes.get("name"));
       }]]>
   </scriptdef>
   
   <!-- Macro uses element -->
   <macrodef name="complex_macro">
       <sequential>
          <cur:elem name="macro element" />
       </sequential>
   </macrodef>

   <!-- Script for testing some ideas -->
   <scriptdef name="complex_script" language="javascript">
       <!-- This is not working as expected.
          Error is:
          build.xml:12: <antlib:complex:complex_script> is unable to create
the <elem> nested element
       -->
       <element name="elem" type="cur:elem"/>

       <!-- This is Ok, but requires fully specified java package for current
antlib -->
       <!-- element name="elem" type="antlib:complex:elem"/-->
       <![CDATA[{
           self.log("elements inside script:");
       var elems = elements.get("elem");
       if (elems) {
               for (i = 0; i < elems.size(); ++i) {
               var elem = elems.get(i);
               elem.perform();
               }
       }
       }]]>
   </scriptdef>
</antlib>

# build.xml
<?xml version="1.0"?>
<project name="elem_testing" default="test" basedir="."
   xmlns:my_lib="antlib:complex">

   <taskdef uri="antlib:complex"
               resource="complex/antlib.xml"
               classpath="."/>

   <target name="test" >
     <my_lib:elem name="single element" />
      <my_lib:complex_macro />
      <my_lib:complex_script>
     <my_lib:elem name="element in script" />
  </my_lib:complex_script>
   </target>
</project>


Vladimir.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.