GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / scripts / CreateApp.groovy
blob41335c8f76e8986d0fc6d3170db7ce3d7c4f7879
1 /*
2 * Copyright 2004-2005 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /**
18 * Gant script that handles the creation of Grails applications
20 * @author Graeme Rocher
22 * @since 0.4
25 import org.codehaus.groovy.grails.commons.GrailsClassUtils as GCU
27 grailsAppName = ""
29 Ant.property(environment:"env")
30 grailsHome = Ant.antProject.properties."env.GRAILS_HOME"
32 includeTargets << new File ( "${grailsHome}/scripts/Package.groovy" )
35 target ( "default" : "Creates a Grails project, including the necessary directory structure and commons files") {
36 createApp()
39 target( createApp: "The implementation target") {
40 depends( appName, createStructure, updateAppProperties, init )
42 createIDESupportFiles()
44 classpath()
45 //loadPlugins()
46 //generateWebXml()
48 // Set the default version number for the application
49 Ant.propertyfile(file:"${basedir}/application.properties") {
50 entry(key:"app.version", value:"0.1")
51 entry(key:"app.servlet.version", value:servletVersion)
54 event("StatusFinal", ["Created Grails Application at $basedir"])
57 target( createIDESupportFiles: "Creates the IDE suppot files (Eclipse, TextMate etc.) project files") {
58 Ant.copy(todir:"${basedir}") {
59 fileset(dir:"${grailsHome}/src/grails/templates/ide-support/eclipse",
60 excludes:".launch")
62 Ant.copy(todir:"${basedir}", file:"${grailsHome}/src/grails/build.xml")
63 Ant.copy(file:"${grailsHome}/src/grails/templates/ide-support/eclipse/.launch",
64 tofile:"${basedir}/${grailsAppName}.launch", overwrite:true)
65 Ant.copy(file:"${grailsHome}/src/grails/templates/ide-support/textmate/project.tmproj",
66 tofile:"${basedir}/${grailsAppName}.tmproj", overwrite:true)
69 Ant.replace(dir:"${basedir}",includes:"*.*",
70 token:"@grails.libs@", value:"${getGrailsLibs()}" )
71 Ant.replace(dir:"${basedir}", includes:"*.*",
72 token:"@grails.jar@", value:"${getGrailsJar()}" )
73 Ant.replace(dir:"${basedir}", includes:"*.*",
74 token:"@grails.version@", value:"${grailsVersion}" )
77 def appKey = grailsAppName.replaceAll( /\s/, '.' ).toLowerCase()
79 Ant.replace(dir:"${basedir}", includes:"*.*",
80 token:"@grails.project.name@", value:"${grailsAppName}" )
81 Ant.replace(dir:"${basedir}", includes:"*.*",
82 token:"@grails.project.key@", value:"${appKey}" )
85 target ( appName : "Evaluates the application name") {
86 if(!args) {
87 Ant.input(message:"Application name not specified. Please enter:",
88 addProperty:"grails.app.name")
89 grailsAppName = Ant.antProject.properties."grails.app.name"
91 else {
92 grailsAppName = args.trim()
93 if(grailsAppName.indexOf('\n') > -1)
94 grailsAppName = grailsAppName.replaceAll(/\n/, " ")
96 basedir = "${basedir}/${grailsAppName}"
97 appClassName = GCU.getClassNameRepresentation(grailsAppName)