I'm writing a custom Ant task that needs to accept a custom nested type.
According to the Ant manual, I should be able to use addConfigured(TYPE x) rather than addConfiguredTYPE(TYPE x). Also, according to this article (section New Reflection rules, Polymorphism in Ant 1.6) support for addConfigured(TYPE x) was added in Ant 1.6.
<taskdef name="custom-task" classname="com.acme.CustomTask">
<classpath refid="task.classpath" />
</taskdef>
<typedef name="custom-type" classname="com.acme.CustomTask$CustomType">
<classpath refid="task.classpath" />
</typedef>
...
<custom-task>
<custom-type/>
</custom-task>
The task is implemented in Java
public class CustomTask extends Task
{
...
public void addConfigured( CustomType t )
{...}
....
public static class CustomType
{...}
}
When I try to run the build script, I get the following exception:
Build Failed: custom-task doesn't support the nested "custom-type" element.
However, when I change
<typedef name="custom-type" classname="com.acme.CustomTask$CustomType">
...
<custom-task>
<custom-type/>
</custom-task>
...
public void addConfigured( CustomType t )
to
<typedef name="customtype" classname="com.acme.CustomTask$CustomType">
...
<custom-task>
<customtype/>
</custom-task>
...
public void addConfiguredCustomType( CustomType t )
everything works as expected.
Is there a reason why the generic addConfigured( TYPE x ) technique does not seem to work in my case?
Other people here and here were having the same problem.
PS: Ant version 1.7.0