Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 68 lines (56 sloc) 2.2 kb
7995c9f graemerocher ignoring test temporarily, as due to infrastructure issues it is not abl...
graemerocher 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 target (default: "Creates a new scaffolding controller for a domain class") {
30 depends(checkVersion, parseArguments)
31
32 def suffix = "Controller"
33 promptForName(type: "Domain Class")
34
35 for (name in argsMap["params"]) {
36 name = purgeRedundantArtifactSuffix(name, suffix)
37
38 // Does the corresponding domain class exist?
39 def dcFile = new File("${basedir}/grails-app/domain", name.replace('.' as char, '/' as char) + ".groovy")
40 if (!dcFile.exists()) {
41 grailsConsole.error "No domain class found for '$name'"
42 exit 1
43 }
44
45 createArtifact(
46 name: name,
47 suffix: suffix,
48 type: "ScaffoldingController",
49 path: "grails-app/controllers",
50 skipPackagePrompt: true)
51
52 def viewsDir = "${basedir}/grails-app/views/${propertyName}"
53 ant.mkdir(dir:viewsDir)
54 event("CreatedFile", [viewsDir])
55
56 createUnitTest(name: name, suffix: suffix, superClass: "ControllerUnitTestCase", skipPackagePrompt: true)
57 }
58
59 }
22c9ebd Alexander Zeillinger GRAILS-9714 Add usage descriptions to several scripts
alexanderzeillinger authored
60
61 USAGE = """
62 create-scaffold-controller [NAME]
63
64 where
65 NAME = The name, including package, of the domain class to create
66 a scaffolded controller for. If not provided, this
67 command will ask you for the name.
68 """
Something went wrong with that request. Please try again.