Variable expansion in gradle.properties


(Adam Kaufman) #1

I am migrating a project from ant that has lots of paths in its build.properties files. I would like to be able to define properties in gradle.properties that can then be expanded into other properties:

rootDir=/home/user/root
aLeafDir=${rootDir}/path/to/leaf
bLeafDir=${rootDir}/path/to/another/leaf

This functionality is available in ant’s properties files. Is it possible in Gradle? I’m using 1.10, and haven’t been able to get it working. I also haven’t found any questions like this anywhere on the interwebs – it’s possible that I’m just doing something really silly. That said, if I println aLeafDir as defined above, I get:

${rootDir}/path/to/leaf

Anything I can do here?


(Peter Niederwieser) #2

It’s a plain properties file, so you can’t expand properties. You can do this in any build script though. Personally, I don’t like to put user-defined properties into ‘gradle.properties’, as properties files are very limited.