ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladimir Volod'ko <us...@unipro.ru>
Subject Does scriptdef <element> use ant:current xmlns when defined in antlib?
Date Mon, 11 Jun 2007 05:34:00 GMT
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@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message