Skip to content

Commit 549316c

Browse files
jameskleehgraemerocher
authored andcommitted
Check setting before running bootstrap. Set setting in commands based on property (#10042)
1 parent 8c9aee2 commit 549316c

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

grails-console/src/main/groovy/grails/ui/command/GrailsApplicationContextCommandRunner.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package grails.ui.command
1717

18+
import grails.config.Settings
1819
import grails.dev.commands.ApplicationContextCommandRegistry
1920
import grails.dev.commands.ExecutionContext
2021
import grails.ui.support.DevelopmentGrailsApplication
@@ -44,6 +45,11 @@ class GrailsApplicationContextCommandRunner extends DevelopmentGrailsApplication
4445
def command = ApplicationContextCommandRegistry.findCommand(commandName)
4546
if(command) {
4647

48+
Object skipBootstrap = command.hasProperty("skipBootstrap")?.getProperty(command)
49+
if (skipBootstrap instanceof Boolean && !System.getProperty(Settings.SETTING_SKIP_BOOTSTRAP)) {
50+
System.setProperty(Settings.SETTING_SKIP_BOOTSTRAP, skipBootstrap.toString())
51+
}
52+
4753
ConfigurableApplicationContext ctx = null
4854
try {
4955
ctx = super.run(args)

grails-core/src/main/groovy/grails/config/Settings.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,5 +210,9 @@ interface Settings {
210210
* Whether to use the legacy JSON builder
211211
*/
212212
String SETTING_LEGACY_JSON_BUILDER = "grails.json.legacy.builder";
213+
/**
214+
* Whether to execute Bootstrap classes
215+
*/
216+
String SETTING_SKIP_BOOTSTRAP = "grails.bootstrap.skip";
213217

214218
}

grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersGrailsPlugin.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ class ControllersGrailsPlugin extends Plugin {
8484
boolean resourcesEnabled = config.getProperty(Settings.RESOURCES_ENABLED, Boolean, true)
8585
String resourcesPattern = config.getProperty(Settings.RESOURCES_PATTERN, String, Settings.DEFAULT_RESOURCE_PATTERN)
8686

87-
bootStrapClassRunner(BootStrapClassRunner)
87+
if (!Boolean.parseBoolean(System.getProperty(Settings.SETTING_SKIP_BOOTSTRAP))) {
88+
bootStrapClassRunner(BootStrapClassRunner)
89+
}
90+
8891
tokenResponseActionResultTransformer(TokenResponseActionResultTransformer)
8992

9093
def catchAllMapping = [Settings.DEFAULT_WEB_SERVLET_PATH]

0 commit comments

Comments
 (0)