I’ve packaged a custom task into a jar with some custom resource files.When I use the task by either adding it to the classpath via a buildscript {…} closure or by adding it to /lib, the task fails to load the resource file. You can see from the method below that I’ve tried nearly all the ways java provides for loading a resource. The ‘url’ variable is always null.
def buildFile(path) {
//def url = RefreshSchema.class.getResource(path)
//def url = getClass().getResource(path)
def url = getClass().getClassLoader().getResource(path)
//def url = ClassLoader.getSystemResource(path)
//def url = ClassLoader.getResource(path)
println(‘url is:’ + url.toString() + ’ for path:’ + path)
return new File(new URI(url.toString()))
}
I confirmed the resource file is in the jar. I printed the contents of the ClassLoader.getURLs() to make sure my task’s jar is on teh classpath. Not sure where else this could have gone wrong