No method for JettyPluginWebAppContext.setBaseResource(ResourceCollection)

I am trying to use jetty plugin and doing some custom configuration on jettyRun task like below:

import org.mortbay.resource.ResourceCollection
import org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext
  apply plugin: 'jetty'
webAppDirName = relativePath(processTestResources.destinationDir)
jettyRun {
 dependsOn processTestResources
 contextPath = '/flp'
 webAppConfig = new JettyPluginWebAppContext()
 webAppConfig.setBaseResource(new ResourceCollection(['..'] as String[]))
}

However, there is an error

A problem occurred evaluating project ‘:xs-mlm-flp’. > No signature of method: org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext.setBaseResource() is applicable for argument types: (org.mortbay.resource.ResourceCollection) values: [file:/home/rice/Dropbox/xsf/;]

Possible solutions: setBaseResource(org.mortbay.resource.Resource), getBaseResource()

This is really weird because setBaseResource(org.mortbay.resource.Resource) is the right method since ResourceCollection is a subclass of Resource. Why groovy does not select it?

change the statement

webAppConfig.setBaseResource(new ResourceCollection(['..'] as String[]))

to

webAppConfig.baseResource = new ResourceCollection(['..'] as String[])

. The error shows

Cannot cast object ‘file:/C:/Users/user/Dropbox/xsf/;’ with class ‘org.mortbay.resource.ResourceCollection’ to class ‘org.mortbay.resource.Resource’

But org.mortbay.resource.ResourceCollection is a subclass of org.mortbay.resource.Resource, the type casting should work. Does this have anything to do with classloaders?

Rice

Could be. Does the subclass relationship also hold in Jetty 6? That’s what the Jetty plugin is using.

Yes, my build.gradle is based on gradle 1.9.