Created
February 11, 2012 20:59
-
-
Save padcom/1804182 to your computer and use it in GitHub Desktop.
Grails script that creates a Zip archive for deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import grails.util.BuildScope | |
scriptScope = BuildScope.WAR | |
includeTargets << grailsScript("_GrailsWar") | |
includeTargets << grailsScript("_GrailsPackage") | |
target(prepareDistributionPackage: 'Creates a Zip archive for deployment') { | |
depends(checkVersion, configureWarName, war) | |
def outputFile = config.deployment.file ?: "${grailsAppName}-${metadata.getApplicationVersion()}.zip" | |
def tomcatVersion = config.deployment.tomcat.version ?: "7.0.25" | |
def tomcatUrl = config.deployment.tomcat.url ?: "http://ftp.tpnet.pl/vol/d1/apache/tomcat/tomcat-7/v7.0.25/bin/apache-tomcat-7.0.25.zip" | |
grailsConsole.updateStatus "Generating deployment package..." | |
ant.delete(dir: "target/deployment-creator") | |
ant.mkdir(dir: "target/deployment-creator") | |
grailsConsole.updateStatus "Retrieving Tomcat bundle..." | |
ant.get( | |
src : tomcatUrl, | |
dest: "target/", | |
usetimestamp: true | |
) | |
grailsConsole.updateStatus "Unzipping Tomcat..." | |
ant.unzip( | |
src : "target/apache-tomcat-${tomcatVersion}.zip", | |
dest: "target/deployment-creator/" | |
) | |
grailsConsole.updateStatus "Renaming Tomcat folder to ${grailsAppName}..." | |
ant.rename( | |
src : "target/deployment-creator/apache-tomcat-${tomcatVersion}", | |
dest: "target/deployment-creator/${grailsAppName}" | |
) | |
grailsConsole.updateStatus 'Updating shared classpath to include ${catalina.base}/conf folder...' | |
ant.propertyfile(file: "target/deployment-creator/${grailsAppName}/conf/catalina.properties") { | |
entry(key: 'shared.loader', operation: '+', value: '${catalina.base}/conf') | |
} | |
grailsConsole.updateStatus 'Copying WAR to deployment folder...' | |
ant.copy( | |
file : "${warName}", | |
todir: "target/deployment-creator/${grailsAppName}/webapps" | |
) | |
grailsConsole.updateStatus 'Creating deployment archive...' | |
ant.zip( | |
destfile: "target/${outputFile}", | |
basedir : "target/deployment-creator" | |
) | |
grailsConsole.updateStatus "Done creating deployment archive target/${outputFile}" | |
} | |
setDefaultTarget('prepareDistributionPackage') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have tried a similar script, but the war that gets generated uses the dev datasource and environment. The war this script produces is always 2k more than one created via "grails war". Even if you use "grails prod myscript", it still produces a war using dev datasource. Has anyone found a way to specify the environtment used in such a script which "depends" on "war"?