4

For example:

Config.groovy:

// ...
grails.variable1 = "a"
grails.varibale2 = "${grails.variable1}bc"
//...

UPDATE 1

Way shown above works with grails 2.2.3. For older versions of grails please use solution @tim_yates suggested

1 Answer 1

9

You need to declare a variable:

def rootVar = 'a'
grails.variable1 = rootVar
grails.varibale2 = "${rootVar}bc"

Or you might be able to do it via a closure (not tested):

grails.variable1 = 'a'
grails.varibale2 = { -> "${grails.variable1}bc" }()
5
  • this is not going to work. I need to access config context somehow. I need to refer to many config variables from many other config variables
    – Archer
    Aug 30, 2013 at 9:31
  • 1
    You can't access the config from inside the config unless it's done via a Closure... Updated my answer...
    – tim_yates
    Aug 30, 2013 at 9:38
  • 1
    @archer Actually, your way seems work with Grails 2.3.0.RC2... I need to run some tests
    – tim_yates
    Aug 30, 2013 at 9:41
  • Thank you. I'll check with 2.3.0.RC2 myself
    – Archer
    Aug 30, 2013 at 9:44
  • ;) nice to hear that.
    – Archer
    Aug 30, 2013 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.