Saturday, August 20, 2011

wsimport depends/produces

Working with the wsimport Ant task, you may come across this warning:

Consider using <depends>/<produces> so that wsimport won't do unnecessary compilation

For whatever reason these nested elements were left out of the documentation.  I borrowed some wording from the JAXB documentation and wrote this amendment:

depends
Files specified with this nested element will be taken into account when the task does a modification date check.  For proper syntax, see <fileset>.

produces
Files specified with this nested element will be taken into account when the task does a modification date check.  For proper syntax, see <fileset>.

Example:
<wsimport
    wsdl="${local-wsdl-path}"
    destdir="${build.dir}"
    sourcedestdir="${src.generated.dir}">
    <depends file="${local-wsdl-path}"/>
    <produces dir="${src.generated.dir}"/>
</wsimport>

This wsimport example specifies a depends/produces relationship between a local WSDL file and the generated source directory. If the WSDL file has a modification date more recent than the generated directory, the wsimport task will regenerate and recompile the source code.