Currently I’m working on the migration from Maven to Gradle. I have to say Gradle is perfect and make things easier.
Now I have a requirement that I’ve tried many ways to figure out but I can’t, the thing is that I want to add an external jar for jettyRun task since our project is using an mock authentication service which is a filter and configured in webdefault.xml for jetty.
I’ve tried:
Add a dependency in buildscript as I remembered the external jar file which is required by build script can be added in this block. But it doesn’t work.
Define a configuration and add this configuration to jettyRun.classpath, but according to the documentation, the property classpath is used for web application not for jetty itself.
Any of above solution will result in CLASS NOT FOUND issue. I guess the reason is because the mock filer is configured in webdefault.xml and this filer should be on the classpath when starting jetty (at this time, the web application is still pending)
I’m not very familiar with the ‘JettyRun’ plugin, but it looks like you could use war.additionalRuntimeJars for this purpose. These jars are added to the context ClassLoader when starting Jetty.
Something like (untested):
war {
additionalRuntimeJars = configurations.mockservice
}
I know this property, and jettyRun has it as well. In Gradle user guide, it explains this property like this: The classpath to make available to the web application.
Literally, I guess this property is only for web application, it’s similar as property classpath.
My project is using spring as well, and I was trying to configure spring context listener in the webdefault.xml and still got the class not found issue, this verified that all jar files configured in the dependencies won’t be loaded for jetty plugin when jetty is started up in the first place.
It appears that only directories work, not individual files? Is this expected? I was trying to add a property file, but it only works if I specify the parent directory of the file, but not when I specify the file directly. The doco doesn’t really clarify this and the source appears to literally pass the path in to jetty…