I have a Gradle build script which has to instantiate a Java class in a Task and call a method on the created object. Currently, I have the following:
apply
The dependency compile files("libs/some.library.jar")
is added as a project dependency not as the script dependency itself. What You need to do is to add this dependency in script's classpath
scope.
apply plugin: 'java'
buildscript {
dependencies {
classpath files("libs/some.library.jar")
}
}
task A << {
def obj = new some.library.TestClass()
obj.doSomething()
}
Now it should work.