On 6/11/07, Vladimir Volod'ko <[EMAIL PROTECTED]> wrote:
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 not (currently) supported.
If it did work the format would be type="ant:current:elem", but
that does not work as well. The "ant:current" namespace is
only available during parsing time - and not during execute time,
so some plumbing needs to be put in place in ant-core to
support it.
Please file a bug, it should be possible to fix when some
bandwidth is available.
Peter
<!-- 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]