Changing a property value depending on the task


(James Maddison) #1

For my project I have a java properties file in the resources. In that properties file (amongst other things) is some SQL info for the application such as the server and the database name.

When I am developing the application I want it to use my dev databse, i.e. “mydb-dev” However when I do a release build I want that property to be changed to the non-dev db, i.e. “mydb”

I already have a release task, this builds a fat jar, names it with the current version and increments the build number. Is there a way I can extend it to change this properties value without having to create multiple properties files that I have to keep sync’d?


(Benjamin Muschko) #2

You might be able to handle this in your build code if you stick to certain conventions (for example you always remove the String ‘-dev’). You have full control over your build. Everything that you can implement with Groovy is possible here.


(James Maddison) #3

I was hoping I wouldn’t have to remember to remove the “-dev” part as I’m bound to forget at one point in the future.