2

Is there a way how to specify system property in (already started) grails interactive mode ?

For example I would specify environment in command line:

grails -Dgrails.env=staging run-app

but in interactive mode it is not possible this way (since JVM is already started):

grails
grails> -Dgrails.env=staging run-app
david
  • 2,529
  • 1
  • 34
  • 50
verglor
  • 616
  • 7
  • 21

1 Answers1

2

This seems to work in Grails 1.3.7 interactive mode. Add a script to your Grails application at scripts/SetProperty.groovy:

includeTargets << grailsScript('_GrailsArgParsing')

target (default:'Set a system property') {
    depends('parseArguments')
    if (argsMap['params'][0] && argsMap['params'][1]) {
        System.setProperty(argsMap['params'][0], argsMap['params'][1])
    } else {
        println 'You must define a property to set'
    }
}

Then in interactive mode set-property grails.env staging.

schmolly159
  • 3,881
  • 17
  • 26