@groovy.transform.CompileStatic class GrailsCompileStaticOptions extends java.lang.Object implements java.io.Serializable
Lazy opt-ins for compiling Grails artefacts with @GrailsCompileStatic automatically,
configured through the nested grails { compileStatic { }} block:
grails {
compileStatic {
controllers = true
services = true
tagLibs = true
}
}
Every flag is a lazy Property that defaults to false and is read when the Groovy
compile task runs (not at configuration time), so the values reflect the user's grails { }
block regardless of configuration ordering. The all flag is a shortcut that enables
controllers, services and tag libraries together.
A class that declares its own @CompileDynamic (or @CompileStatic /
@GrailsCompileStatic / @TypeChecked / @GrailsTypeChecked) annotation always
keeps that setting; these build-wide opt-ins never override an explicit per-class choice.
| Type | Name and description |
|---|---|
Property<java.lang.Boolean> |
allWhat every artefact type falls back to where it says nothing of its own. |
Property<java.lang.Boolean> |
controllersWhether every controller under grails-app/controllers should be compiled with
@GrailsCompileStatic. |
SetProperty<java.lang.String> |
dynamicTagNamespacesNamespaces whose tag libraries are registered while the application runs rather than described when it is compiled. |
Property<java.lang.Boolean> |
gspWhether every GSP page under grails-app/views should be compiled statically, by stating
the grails.views.gsp.compileStatic configuration setting for both the build and the
running application. |
Property<java.lang.Boolean> |
servicesWhether every service under grails-app/services should be compiled with
@GrailsCompileStatic. |
Property<java.lang.Boolean> |
strictGspWhether every page is held to the names it declares, rather than only the pages that declare a model. |
Property<java.lang.Boolean> |
strictTagsWhether a tag no compiled tag library declares should fail compilation. |
Property<java.lang.Boolean> |
tagLibsWhether every tag library under grails-app/taglib should be compiled with
@GrailsCompileStatic. |
Property<java.lang.Boolean> |
unqualifiedTagCallsWhether a tag call written without its namespace may be compiled into a direct invocation. |
| Constructor and description |
|---|
GrailsCompileStaticOptions(ObjectFactory objects) |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
What every artefact type falls back to where it says nothing of its own. A shortcut for enabling controllers, services and tagLibs together. Disabled by default.
An artefact type that states a value keeps it, so a single type can be held back from the shortcut:
grails {
compileStatic {
all = true
services = false // every artefact type but services
}
}
Whether every controller under grails-app/controllers should be compiled with
@GrailsCompileStatic. Follows all where it is not set.
Namespaces whose tag libraries are registered while the application runs rather than described when it is compiled. Tags in them are never reported as unknown, however complete the tag library index is, and calls to them keep being dispatched dynamically.
Whether every GSP page under grails-app/views should be compiled statically, by stating
the grails.views.gsp.compileStatic configuration setting for both the build and the
running application. Disabled by default.
Deliberately not covered by all. The artefact opt-ins fail on code that is doubtful anyway; this one fails on a page that reads a model variable it has not declared, which describes most pages in an application that has never declared one. Enabling it is a migration, not a switch, so it is never turned on as a side effect of asking for everything.
Whether every service under grails-app/services should be compiled with
@GrailsCompileStatic. Follows all where it is not set.
Whether every page is held to the names it declares, rather than only the pages that declare a model. Disabled by default.
A page that declares a model is held to it either way: declaring one states what the page is rendered with, so a name outside it is a mistake. This asks for the same of a page that declares nothing, which otherwise reads what it is rendered with the way a dynamically compiled page does. Meaningless unless gsp is enabled.
Whether a tag no compiled tag library declares should fail compilation. Disabled by default, where such a tag is left to resolve at runtime with nothing reported.
Checked only where the source says a call is a tag: one naming its namespace, as
g.message(code: 'x') does, and one written as markup, as <g:message/> is. A call
written without a namespace is not checked, because such a name may equally be a method
contributed by any of the dynamic mechanisms an application has, and in a page it may be part of
the model the page was rendered with.
Knowing that a namespace holds some compiled tag libraries is not the same as knowing it holds all of them: a plugin built before tag library descriptors existed contributes tags without one, and a tag library registered while an application runs contributes more. Enable this once every tag library an application uses is described, and declare the namespaces that are genuinely filled in at runtime through dynamicTagNamespaces:
grails {
compileStatic {
strictTags = true
dynamicTagNamespaces = ['legacy']
}
}
Whether every tag library under grails-app/taglib should be compiled with
@GrailsCompileStatic. Follows all where it is not set.
Whether a tag call written without its namespace may be compiled into a direct invocation.
Off by default. A namespaced call names the tag library it means; a bare name is a tag only when nothing nearer answers to it, and what answers to it is not fully visible when compiling - a method Groovy gives every object, a delegate an enclosing closure is handed, an overload the tag library also declares. Turn this on to compile those calls too, in a project whose tag names are known not to collide.