Use of external jar class in custom plugin

Hi,

I have a question about use of external dependencies in my custom plugin. Consider the following task

dependencies {
    cxfCodeGenLibs "org.apache.cxf:cxf-tools-wsdlto-core:2.5.+"
}
  task("WSDL2JAVA", type: JavaExec) {
    main = 'org.apache.cxf.tools.wsdlto.WSDLToJava'
    classpath = configurations.cxfCodeGenLibs
    //+args and some other stuff
}

I want to write a plugin, that will add such task to my project and will execute code generation inside “@TaskAction” method.

What is the right way of using org.apache.cxf.tools.wsdlto.WSDLToJava in my plugin? For example, i can take cxfCodeGenLibs configuration and load the class by classloader, but it looks very ugly… Another approach is to make libs as compile dependency for my plugin and use simple imports, but how to provide this dependencies at plugin task execution?

Thanks in advance.

Another approach is to make libs as compile dependency for my plugin and use simple imports, but how to provide this dependencies at plugin task execution?

For a plugin that lives in ‘buildSrc’ or gets published to an Ivy or Maven repository, ‘compile’ and ‘runtime’ dependencies will automatically be pulled in by transitive dependency management.

Wow, nice feature. Thanks, Peter!