Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 114 lines (98 sloc) 4.22 kB
3e17890 1.1 branch is now trunk
graeme authored
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.
15 */
16
17 /**
835947f @burtbeckwith cleanup
burtbeckwith authored
18 * Gant script that handles general initialization of a Grails applications
19 *
20 * @author Graeme Rocher
21 *
22 * @since 0.4
23 */
3e17890 1.1 branch is now trunk
graeme authored
24
25 import org.springframework.core.io.FileSystemResource
26 import grails.util.GrailsNameUtils
27 import groovy.grape.Grape
28 import grails.util.Metadata
29
85c9085 @pledbrook Removed more 'target ovewriting' warnings due to GWT plugin's _Events…
pledbrook authored
30 // No point doing this stuff more than once.
31 if (getBinding().variables.containsKey("_init_called")) return
32 _init_called = true
33
3e17890 1.1 branch is now trunk
graeme authored
34 Grape.enableAutoDownload = true
35
36 // add includes
37 includeTargets << grailsScript("_GrailsArgParsing")
38 includeTargets << grailsScript("_PluginDependencies")
39
40 target(createStructure: "Creates the application directory structure") {
41 ant.sequential {
42 mkdir(dir: "${basedir}/src")
43 mkdir(dir: "${basedir}/src/java")
44 mkdir(dir: "${basedir}/src/groovy")
45 mkdir(dir: "${basedir}/grails-app")
46 mkdir(dir: "${basedir}/grails-app/controllers")
47 mkdir(dir: "${basedir}/grails-app/services")
48 mkdir(dir: "${basedir}/grails-app/domain")
49 mkdir(dir: "${basedir}/grails-app/taglib")
50 mkdir(dir: "${basedir}/grails-app/utils")
51 mkdir(dir: "${basedir}/grails-app/views")
52 mkdir(dir: "${basedir}/grails-app/views/layouts")
53 mkdir(dir: "${basedir}/grails-app/i18n")
54 mkdir(dir: "${basedir}/grails-app/conf")
55 mkdir(dir: "${basedir}/test")
56 mkdir(dir: "${basedir}/test/unit")
57 mkdir(dir: "${basedir}/test/integration")
58 mkdir(dir: "${basedir}/scripts")
59 mkdir(dir: "${basedir}/web-app")
60 mkdir(dir: "${basedir}/web-app/js")
61 mkdir(dir: "${basedir}/web-app/css")
62 mkdir(dir: "${basedir}/web-app/images")
63 mkdir(dir: "${basedir}/web-app/META-INF")
64 mkdir(dir: "${basedir}/lib")
65 mkdir(dir: "${basedir}/grails-app/conf/spring")
66 mkdir(dir: "${basedir}/grails-app/conf/hibernate")
67 }
68 }
69
0817216 @graemerocher reverted change to checkVersion
graemerocher authored
70 target(checkVersion: "Stops build if app expects different Grails version") {
71 if (metadataFile.exists()) {
72 if (appGrailsVersion != grailsVersion) {
73 event("StatusFinal", ["Application expects grails version [$appGrailsVersion], but GRAILS_HOME is version " +
835947f @burtbeckwith cleanup
burtbeckwith authored
74 "[$grailsVersion] - use the correct Grails version or run 'grails upgrade' if this Grails " +
75 "version is newer than the version your application expects."])
0817216 @graemerocher reverted change to checkVersion
graemerocher authored
76 exit(1)
77 }
835947f @burtbeckwith cleanup
burtbeckwith authored
78 }
79 else {
43bd61b @graemerocher improve error message
graemerocher authored
80 event("StatusFinal", ["Application metadata not found, please run: grails upgrade"])
0817216 @graemerocher reverted change to checkVersion
graemerocher authored
81 exit(1)
82 }
83 }
84
3e17890 1.1 branch is now trunk
graeme authored
85 target(updateAppProperties: "Updates default application.properties") {
86 def entries = [ "app.name": "$grailsAppName", "app.grails.version": "$grailsVersion" ]
87 if (grailsAppVersion) {
88 entries["app.version"] = "$grailsAppVersion"
89 }
90 updateMetadata(entries)
91
92 // Make sure if this is a new project that we update the var to include version
93 appGrailsVersion = grailsVersion
94 }
95
835947f @burtbeckwith cleanup
burtbeckwith authored
96 target(launderIDESupportFiles: "Updates the IDE support files (Eclipse, TextMate etc.), changing file names and replacing tokens in files where appropriate.") {
267ef48 @graemerocher Grails no longer creates eclipse, intellij, textmate or ant build fil…
graemerocher authored
97 // do nothing. deprecated target
3e17890 1.1 branch is now trunk
graeme authored
98 }
99
100 target(init: "main init target") {
101 depends(createStructure, updateAppProperties)
102
103 grailsUnpack(dest: basedir, src: "grails-shared-files.jar")
104 grailsUnpack(dest: basedir, src: "grails-app-files.jar")
105
106 classpath()
107
108 // Create a message bundle to get the user started.
109 touch(file: "${basedir}/grails-app/i18n/messages.properties")
110
835947f @burtbeckwith cleanup
burtbeckwith authored
111 // Set the default version number for the application
9a0040c no need to set servlet api version in application.properties since th…
Burt Beckwith authored
112 updateMetadata("app.version": grailsAppVersion ?: "0.1")
3e17890 1.1 branch is now trunk
graeme authored
113 }
Something went wrong with that request. Please try again.