Reputation: 69
Let's say if we defined property value which includes groovy expression in gradle.properties file:
databaseFile = ${System.properties['user.home']}/.derby
Later when I want to access this property value in gradle build script,
it seems that it was loaded as pure java String in groovy runtime without string evaluation.
Are there any methods that could help me evaluate pure java String before I get the property value via gradle dsl?
Or I have to evaluate the java String I've got in runtime? But how to make that?
Thank you~
Upvotes: 0
Views: 1125
Reputation: 24333
Assuming:
databaseFile_unevaluated = '${System.properties[\'user.home\']}/.derby'
You might be able to evaluate it as a GString
using Eval
:
databaseFile = Eval.me(""" "$databaseFile_unevaluated" """)
This could also be written as:
databaseFile = Eval.me("\"$databaseFile_unevaluated\"")
Upvotes: 2