@groovy.transform.CompileStatic class GrailsExtension extends java.lang.Object
A extension to the Gradle plugin to configure Grails settings
| Type | Name and description |
|---|---|
static java.lang.String |
DEFAULT_BOMThe default Grails BOM artifact name applied when bom is not overridden. |
Property<java.lang.String> |
bomThe Grails BOM that the Grails Gradle plugin automatically applies as a Gradle platform() (or enforcedPlatform() for the Micronaut variants) on every
declarable project configuration, alongside the
org.apache.grails.gradle.bom-property-overrides plugin for property-based
version overrides. |
GrailsCompileStaticOptions |
compileStaticLazy opt-ins for compiling controllers, services and tag libraries with @GrailsCompileStatic
automatically, configured through the nested compileStatic block. |
boolean |
importGrailsCommonAnnotationsWhether grails annotation packages and common validation annotations should be default import packages. |
boolean |
importJavaTimeWhether java.time.* package should be a default import package |
Property<java.lang.Boolean> |
indyWhether to enable Groovy's invokedynamic (indy) bytecode instruction for dynamic Groovy method dispatch. |
boolean |
micronautAutoSetupWhether the Micronaut auto-setup should run when the `grails-micronaut` plugin is detected. |
boolean |
native2asciiWhether to invoke native2ascii on resource bundles |
boolean |
native2asciiAntWhether to use Ant to do the conversion |
boolean |
packageAssetsWhether assets should be packaged in META-INF/assets for plugins |
PluginDefiner |
pluginDefiner |
Property<java.lang.Boolean> |
preserveParameterNamesKeep method and constructor parameter names in class files, allowing frameworks such as Spring to use parameter names for dependency resolution, including autowiring by name without requiring annotations such as @Qualifier. |
Project |
project |
boolean |
springDependencyManagement
|
java.util.List<java.lang.String> |
starImportsCustom star imports to add to Groovy compilation configuration. |
| Constructor and description |
|---|
GrailsExtension(Project project) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
compileStatic(groovy.lang.Closure<?> configureClosure)Configures the nested compileStatic opt-ins. |
|
DependencyHandler |
getPlugins() |
|
boolean |
isDevelopmentRun() |
|
void |
plugins(groovy.lang.Closure configureClosure)Allows defining plugins in the available scopes |
|
void |
setBom(java.lang.String value)DSL setter for bom. |
|
void |
setIndy(boolean enabled) |
|
void |
setSpringDependencyManagement(boolean enabled)Backward-compatible setter for the deprecated springDependencyManagement flag. |
| 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) |
The default Grails BOM artifact name applied when bom is not
overridden. Resolved as org.apache.grails:grails-bom:$grailsVersion.
The Grails BOM that the Grails Gradle plugin automatically applies as a Gradle
platform() (or enforcedPlatform() for the Micronaut variants) on every
declarable project configuration, alongside the
org.apache.grails.gradle.bom-property-overrides plugin for property-based
version overrides.
The value is the BOM artifact name within the
org.apache.grails group; the plugin resolves it as
org.apache.grails:$bom:$grailsVersion. Exactly one BOM is ever applied.
Defaults to grails-bom. Set it to a different curated variant when the
application needs that BOM instead - for example:
grails {
bom = 'grails-micronaut-bom' // applied as an enforcedPlatform
}
Set it to null (or use the deprecated
grails { springDependencyManagement = false }) to suppress the automatic BOM
application entirely - for example when you want to declare the
platform()/enforcedPlatform() by hand (and apply
org.apache.grails.gradle.bom-property-overrides explicitly if you still
want gradle.properties / ext['...'] overrides):
grails {
bom = null
}
The Micronaut variants (grails-micronaut-bom,
grails-hibernate5-micronaut-bom, and grails-hibernate7-micronaut-bom)
are applied as an enforcedPlatform
because the Micronaut platform would otherwise override their managed versions via
conflict resolution. All other BOMs are applied as a regular platform.
Lazy opt-ins for compiling controllers, services and tag libraries with @GrailsCompileStatic
automatically, configured through the nested compileStatic block. Each flag is a lazy
Property (read at compile time, not configuration time) and defaults to false:
grails {
compileStatic {
controllers = true
services = true
tagLibs = true
}
}
Use compileStatic { all = true } as a shortcut to enable all three at once. A per-class
@CompileDynamic (or @CompileStatic/@GrailsCompileStatic) annotation always
wins over these defaults.
Whether grails annotation packages and common validation annotations should be default import packages. When enabled, automatically imports: - jakarta.validation.constraints.* - grails.gorm.annotation.* (if grails-datamapping-core is in classpath) - grails.plugin.scaffolding.annotation.* (if grails-scaffolding is in classpath)
Whether java.time.* package should be a default import package
Whether to enable Groovy's invokedynamic (indy) bytecode instruction for dynamic Groovy method dispatch. Disabled by default to improve performance (see GitHub issue #15293). When enabled, Groovy uses JVM invokedynamic instead of traditional callsite caching. To enable invokedynamic in build.gradle: grails { indy = true }
Whether the Micronaut auto-setup should run when the `grails-micronaut` plugin is detected. When enabled, the Grails Gradle plugin:
Whether to invoke native2ascii on resource bundles
Whether to use Ant to do the conversion
Whether assets should be packaged in META-INF/assets for plugins
Keep method and constructor parameter names in class files, allowing frameworks such as Spring to use parameter names for dependency resolution, including autowiring by name without requiring annotations such as @Qualifier.
platform() support plus lightweight property-based version overrides
supplied by the org.apache.grails.gradle.bom-property-overrides plugin.
Set version overrides in gradle.properties or via ext['property.name']
instead. For backward compatibility, setting this property to false is still
honored as bom = null so existing opt-outs (which previously prevented
the Spring Dependency Management BOM from being applied) continue to disable the
automatic Grails BOM platform() application. New builds should set
bom directly.Custom star imports to add to Groovy compilation configuration. Users can add their own package imports that will be combined with imports added by importJavaTime and importGrailsCommonAnnotations flags.
Configures the nested compileStatic opt-ins.
configureClosure - a closure applied to the GrailsCompileStaticOptionsAllows defining plugins in the available scopes
DSL setter for bom. A null or blank value clears the property so that
no BOM is applied automatically; any other value is used verbatim as the BOM artifact name.
Backward-compatible setter for the deprecated springDependencyManagement flag.
Disabling it clears bom (equivalent to grails { bom = null }) so projects
that still opt out via grails { springDependencyManagement = false } do not
unexpectedly receive the Grails BOM platform() after the migration away from the
Spring Dependency Management plugin.