Grails

Add a way to ease deployment of different instances of the same application in the same tomcat

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Duplicate
  • Affects Version/s: 1.0.2
  • Fix Version/s: 1.0.3
  • Component/s: Project infrastructure
  • Labels:
    None

Description

I want to deploy the same application many times, in the same tomcat.
But I need to always edit application.properties to change application name so that the grails.project.key is changed in web.xml.
I have done this with little changes to Package.groovy, so I could something like:
grails -Dgrails.env=malabaris -Dapp.name=malabaris -Dproject.key=malabaris my-war

MyWar is the following script:
----------------------------------------------------------------------------------------------------
import org.codehaus.groovy.grails.commons.GrailsClassUtils as GCU

grailsHome = Ant.project.properties."environment.GRAILS_HOME"

includeTargets << new File ( "${grailsHome}/scripts/Init.groovy" )
includeTargets << new File ( "${grailsHome}/scripts/War.groovy" )

target('default': "The description of the script goes here!") {
if(System.getProperty("app.name")) grailsAppName = System.getProperty("app.name")
def tmpWebXml = "${userHome}/.grails/${grailsVersion}/projects/${baseName}/web.xml.tmp"
Ant.delete(file:tmpWebXml, failonerror:false)
war()
}

----------------------------------------------------------------------------------------------------

The thig here is that tmpWebXml must be deleted so it is generated again and grails.project.key is replaced with the correct value.

Changes to Package.groovy were in generateWebXml target:
----------------------------------------------------------------------------------------------------
def grailsProjKey = Ant.antProject.properties.'grails.project.key'
if(System.getProperty("project.key")){
grailsProjKey = System.getProperty("project.key")
}
Ant.replace(file:tmpWebXml, token:"@grails.project.key@", value:"${grailsProjKey}")
----------------------------------------------------------------------------------------------------

With these minor enhancements, I dont need anymore to edit application.properties, and I could create a bat file to each instance of the application.

Felipe

Issue Links

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: