Hidden gem: grails.war.resources
In the process of packaging up the Grails application as a WAR in preparation for deployment to Tomcat, I needed to figure out a way to exclude the Oracle JDBC drver from WEB-INF/lib (we use 'shared' Oracle driver for our web apps which gets loaded by the Catalina's common ClassLoader). So I was thinking of a way to provide an "event hook" script, and while reading Grails' War.groovy I found a "hidden gem". That is a closure which is defined in the application's Config.groovy. So when this closure is defined, the War.groovy calls it with "staging directory" as a parameter and sets Ant as its 'delegate' right before zipping it up as a war.
So I was able to do the following (... from Config.groovy):
//Closure to customize the packaging of a war. In particular it excludes the Oracle JDBC driver
//from the war as it is loaded by the Catalina common ClassLoader when deployed to Tomcat
grails.war.resources = {stagingDir ->
delete(file: "$stagingDir/WEB-INF/lib/ojdbc14-10.2.jar")
}
This is real nice, but I don't think this feature is documented anywhere.
Later...

6 comments:
...Under mild sedation the patient was brought in to the OR and placed on the table in a supine position. A pneumotic ankle tourniqute was placed around patient's left ankle. After the administration of sedative agents, local anesthesia was obtained around the 1st MPJ joint utilizing 20 cc of 1:1 mixture of ... Have a good day :)
And you would say that why? :-)
P.S.
That's my wife having fun with my blog :-)
This is a good strategy, but how would one do this in a more mature technological landscape, such as COBOL/MVS? Could this be done using JCL? Or perhaps, dare I say, a Portal environment?
And why COBOL/MVS, portal is relevant to this post? ;-)
Thanks for this snippet. I was able to setup my Config.groovy to remove all the jars to beat down my war filesize. I made a few changes and documented them on my new site ( with very little content.. )
http://ryantownshend.ca/article/show/2
Instead of this, we have in
scripts/Events.groovy:
eventWarStart = {args ->
Ant.delete(file: "$stagingDir/WEB-INF/lib/jcifs-0.8.3.jar", failOnError: true)
}
Post a Comment