XDoclet Invocation through Ant

XDoclet Invocation through Ant

A sample build target for invoking the plugin that we just wrote might look like this. Infact the <component> element can be used to register any component Pico container is not aware of (Note that Pico registers velocity, template engines and QDox metadata provider etc by default and hence need not be declared in the build file). If we were to write a plugin / custom metadata provider implementation / a template engine! for that matter they can be registered with Pico using the <component> element.

xdoclet2 plugins are hosted here. Download and unzip it to the file system.


Plugin and lowercase attributes on component task declaration

Every plugin / component is likely to expose custom attributes (in addition to the ones defined on the abstract Plugin cass) for customization.

Accordingly Pico's custom <component> ant task implements Ant's interface to support dynamic attributes at the task level. These attribute-value pairs are then registered with Pico that in turn tries to satisfy the plugin's dependency by looking for corresponding setters exposed on the Plugin class. For eg the attribute-value pair "filereplace='hello.xml'" makes Pico invoke setFilereplace('hello.xml') on the abstract Plugin class. When using DynamicConfigurator interface, ant has a tendency to convert all attribute names to lowercase. If a concrete Plugin allows for an attribute named 'servletVersion', its value is likely to be specified in the component task like this.

Unfortunately, as discussed earlier, Ant converts the attribute name to 'servletversion' and Pico would throw an error indicating the absence of such an attribute on the concrete Plugin class. So in order to make sure that the Plugin works correctly when invoked through Ant, it becomes necessary that plugin writers follow a lowercase attribute naming convention!

Powered by Atlassian Confluence