How to translate dependencies to xjctask classpath parameter?

The Ant XJCTask class takes a “classpath” element. I have a set of dependencies that I need to provide for that parameter. How do I translate a list of dependencies into a form required for the “classpath” element? I know how to iterate through the required dependencies, but I don’t understand how to present this into the “classpath” parameter of the XJCTask task.

I tried the obvious “classpath(configurations..asPath)”, but this fails with “class$AntElement doesn’t support nested text data”. I tried printing out this expression just before the “ant.xjc” call, and it looks like a normal PATH-like variable.

I figured this out. The “classpath” element requires a list of “pathelement” elements with a location attribute, pointing to each resulting jar location, so it looks like this:

classpath() {
      configurations.xjc.each {
 File file -> pathelement(location: file)

You can also create a ‘<pathelement>’ that takes a single ‘path’ attribute, which is a bit simpler.

ant.xjc() {

classpath {

pathelement(path: configurations.xjc.asPath)



You can take a look at the Ant documentation for more detail.