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: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
|