Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Gradle custom ant task classpath?

I have a custom Ant task in my codebase that I need to use from Gradle. There are plenty of examples of how to use a task that is packaged in a jar file, but this is different.

My taskdef should look something like:

ant.taskdef(
    name: 'generator',
    classname: 'MyGenerator', 
    classpath: ???
)

The classpath should include everything in bin/ (where my code gets compiled to) and all the jars listed in the dependencies section of the build script. How to fill in the blank?

I've tried a few different things, resulting in either obscure messages like The <taskdef> type doesn't support nested text data or typical NoClassDefFoundError.

like image 456
Dave L. Avatar asked Jan 17 '14 00:01

Dave L.


2 Answers

I think what you want to do is described in the user guide under 'Using custom Ant tasks in your build'

basically you want to declare a configuration, add dependencies to it in the dependencies section and then use asPath in your taskdef classpath

like image 160
Perryn Fowler Avatar answered Sep 29 '22 11:09

Perryn Fowler


As Perryn Fowler wrote, you should declare a configuration and dependencies section. Here is an example I found: https://github.com/openbakery/gradle-common-plugins/blob/master/webdav.gradle

like image 35
Matthias B Avatar answered Sep 29 '22 11:09

Matthias B