How can I amend the classes available to a custom Gradle task?


(Norman Walsh) #1

I wrote a custom Gradle task to encapsulate a Java application, https://github.com/ndw/xmlcalabash1-gradle

It’s a fairly simple extension of org.gradle.api.internal.ConventionTask cobbled together somewhat quickly. It’s entirely possible that I’m just doing it wrong.

It’s been working just fine for a while now. I’ve used it in several projects. However, for the particular build.gradle that I’m writing now, I need to make additional classes available to it.

After much frustration and complete failure to get additional jars into the classpath, I went back and updated my application class so that it would print out its classpath. That revealed that when this task runs, the classpath consists of only /usr/lib/gradle/4.4.1/lib/gradle-launcher-4.4.1.jar. I conclude that some alternate class loader must be in use because the task does successfully load the core application classes.

Can anyone tell me how to make more jars available to my task?


(Norman Walsh) #2

Ah. I thought for a moment that I was just being stupid and that adding them to the buildscript dependencies would work. No such luck.


(Norman Walsh) #3

Nevermind. That was sufficient, I simply left the ‘classpath’ modifier out of the dependencies. Shame that’s not an error of some sort.