Convert task from Groovy to Java

hey-hey,

I’m converting Gradle plugins written in Groovy to Java. I have some tasks using ant, e.g.:

ant.taskdef(name: "wsimport", classname: "com.sun.tools.ws.ant.WsImport", classpath: wsimportClasspath)
ant.wsimport(
  package: packageName,
  sourcedestdir: genJaxbDir,
  wsdl: wsdlFile.toURI()
)

How I can translate this to DefaultTask using Java? I have access to AntBuilder in my task and I can do something like that:

AntBuilder ant = getProject().getAnt();
ant.invokeMethod("echo", "hello, world!");

What I don’t understand, how I can add Ant task definition with name, classpath, parameters etc.

I solved this using JavaExec task (instead of DefaultTask) with following configuration:

setClasspath(getProject().getConfigurations().getByName("wsimport");
setMain("com.sun.tools.ws.WsImport");
// don't forget to set correct 'workingDir' and 'args'