Adding a resource directory to classpath of greety

2019-07-17 15:30发布

问题:

I'm trying to run gradle with the plugin gretty using jetty. The problem is the gretty plugin does put the directory src/test/resources on the classpath and I need a lazy load for some .properties files on the Jetty startup.

dependencies {
    gretty "com.zaxxer:HikariCP:${version_hikaricp}"
    gretty "org.hsqldb:hsqldb:${version_hsqldb}"
    gretty files("target/classes/main", "target/resources/main", "src/test/resources")
}

The code above is not loading the resources to the classpath to be used by the gretty plugin. When we run Jetty we can add our resource files on ${JETTY_BASE}/resources and those files will be present in our classpath. Any idea/trick to get the same feature with grettyplugin?

回答1:

I just found the solution looking into the gretty opened issues. According to the author, this is a feature not documented yet. Here is the solution:

 gretty {
     classPath ['src/test/resources', 'src/main/configs']
 }