Adding directories to the grails classpath when running as a war?
Before开发者_运维知识库, I had this in _Events.groovy:
eventClasspathStart = {
addResourceBundlesToClasspath()
}
However, this isn't fired when I deploy as a war. How can I add directories to the classpath that need to be included with the war as well?
You can configure which files are included in the war in the BuildConfig.groovy anything in /WEB-INF should get picked up in the classpath
// This closure is passed the command line arguments used to start the
// war process.
grails.war.copyToWebApp = { args ->
fileset(dir:"web-app") {
include(name: "js/**")
include(name: "css/**")
include(name: "WEB-INF/**")
}
// This closure is passed the location of the staging directory that
// is zipped up to make the WAR file, and the command line arguments.
// Here we override the standard web.xml with our own.
grails.war.resources = { stagingDir, args ->
copy(file: "grails-app/conf/custom-web.xml", tofile: "${stagingDir}/WEB-INF/web.xml")
}
From http://grails.org/doc/latest/guide/17.%20Deployment.html
You can also specify dependencies in BuildConfig using grails.war.dependencies to include additional libs in the war
def deps = [
"hibernate3.jar",
"groovy-all-*.jar",
"standard-${servletVersion}.jar",
"jstl-${servletVersion}.jar",
"oscache-*.jar",
"commons-logging-*.jar",
"sitemesh-*.jar",
"spring-*.jar",
"log4j-*.jar",
"ognl-*.jar",
"commons-*.jar",
"xstream-1.2.1.jar",
"xpp3_min-1.1.3.4.O.jar" ]
grails.war.dependencies = {
fileset(dir: "libs") {
deps.each { pattern ->
include(name: pattern)
}
}
}`
精彩评论