I’m trying out Grails application hosting at Mor.ph with a free developer account. To put up a sample application, I wanted to be able to protect the site with basic authentication so that it won’t be accidentally found and played with. So, following the Mor.ph instructions, I needed to modify web.xml to add security constraints and a login mechanism.
As with most things Grails, the solution was easy - simply install the templates and modify the web.xml template.
But, at the moment I have to uncomment it in order to get it running locally - what I really need is a way to only put this modification in when the environment is production…


{ 3 comments… read them below or add one }
Look at morph-deploy plugin - it does what you need, unless you do not have several environments on morph for one app.
I am using the morph-deploy plugin, but I don’t see any mention of it adding security constraints to web.xml - it only mentions adding jndi datasource and mail session. I will have a look at the source code for the plugin and see if it handles security constraints, and if not I’ll look into making a contribution…
You could also hook (http://grails.org/doc/1.0.x/guide/4.%20The%20Command%20Line.html#4.3%20Hooking%20into%20Events) into the webXml-Event and do the modification depending on the environment:
_Events.groovy:
—————
import grails.util.GrailsUtil
eventWebXmlEnd = { String tmpfile ->
switch(GrailsUtil.environment) {
case “development”:
// do dev modification
break
case “production”:
// do prod modification
break
}