Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 68 lines (55 sloc) 2.17 kb
a81029e Peter Ledbrook Added a create-scaffold-controller command for easy demoing and getting ...
pledbrook 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 /**
18 * Gant script that creates a new Grails dynamic scaffolding controller
19 * for given domain classes.
20 *
21 * @author Graeme Rocher
22 *
23 * @since 0.4
24 */
25
26 includeTargets << grailsScript("_GrailsInit")
27 includeTargets << grailsScript("_GrailsCreateArtifacts")
28
29 USAGE = """
30 create-scaffold-controller [DOMAIN ...]
31
32 where
33 DOMAIN = The name, including package, of a domain class to create
34 a scaffolding controller for. (default: prompts for a name)
35 """
36
37 target (default: "Creates a new scaffolding controller for a domain class") {
38 depends(checkVersion, parseArguments)
39
40 def suffix = "Controller"
41 promptForName(type: "Domain Class")
42
43 for (name in argsMap["params"]) {
44 name = purgeRedundantArtifactSuffix(name, suffix)
45
46 // Does the corresponding domain class exist?
47 def dcFile = new File("${basedir}/grails-app/domain", name.replace('.' as char, '/' as char) + ".groovy")
48 if (!dcFile.exists()) {
49 grailsConsole.error "No domain class found for '$name'"
50 exit 1
51 }
52
53 createArtifact(
54 name: name,
55 suffix: suffix,
56 type: "ScaffoldingController",
57 path: "grails-app/controllers",
58 skipPackagePrompt: true)
59
60 def viewsDir = "${basedir}/grails-app/views/${propertyName}"
61 ant.mkdir(dir:viewsDir)
62 event("CreatedFile", [viewsDir])
63
64 createUnitTest(name: name, suffix: suffix, superClass: "ControllerUnitTestCase", skipPackagePrompt: true)
65 }
66
67 }
Something went wrong with that request. Please try again.