Skip to content

Commit 1c2d192

Browse files
committed
show warning for static scaffold
1 parent bb6540a commit 1c2d192

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

grails-scaffolding/src/main/groovy/org/grails/compiler/scaffolding/ScaffoldingControllerInjector.groovy

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ import org.grails.core.artefact.ControllerArtefactHandler
3737
import org.grails.plugins.web.rest.transform.ResourceTransform
3838

3939
/**
40-
* Transformation that turns a controller into a scaffolding controller at compile time if 'static scaffold = Foo'
41-
* or '@Scaffold' is specified
40+
* Transformation that turns a controller into a scaffolding controller at compile time if '@Scaffold' is specified.
41+
*
42+
* <p>The legacy 'static scaffold = Foo' syntax is deprecated and will be removed in a future version.
43+
* Use the {@code @Scaffold} annotation instead.</p>
4244
*
4345
* @author Graeme Rocher
4446
* @author Scott Murphy Heiberg
@@ -69,6 +71,21 @@ class ScaffoldingControllerInjector implements GrailsArtefactClassInjector {
6971

7072
def expression = propertyNode?.getInitialExpression()
7173
if (expression instanceof ClassExpression || annotationNode) {
74+
if (expression instanceof ClassExpression && !annotationNode) {
75+
ClassNode domainClassNode = ((ClassExpression) expression).getType()
76+
String domainClassName = domainClassNode.getNameWithoutPackage()
77+
String controllerClassName = classNode.getNameWithoutPackage()
78+
GrailsASTUtils.warning(source, propertyNode, """
79+
The 'static scaffold = ${domainClassName}' syntax is deprecated and will be removed in a future version of Grails.
80+
Please use the @Scaffold annotation instead:
81+
82+
import grails.plugin.scaffolding.annotation.Scaffold
83+
84+
@Scaffold(${domainClassName})
85+
class ${controllerClassName} {
86+
}
87+
""".stripIndent())
88+
}
7289
ClassNode valueClassNode = annotationNode?.getMember('value')?.type
7390
ClassNode superClassNode = ClassHelper.make(RestfulController).getPlainNodeReference()
7491
ClassNode currentSuperClass = classNode.getSuperClass()

0 commit comments

Comments
 (0)