Use properties with your gradle project.

Most of us are used in the maven way of specifying properties by using the properties tag


and then when it comes to a dependency it can be easily referenced as ${springdata.commons}.

This is a bit tricky when it comes to gradle. The way  to do so is by using the extra properties extension.

  springdataCommons = "2.0.9.RELEASE"
dependencies {
    compile "${springdataCommons}"

Be aware that in order for this to work you should use double quotes, since in groovy double-quoted String literals support String interpolation while single quoted don’t.

This might work for you but you might want to use the dot character, for example springdata.commons .

That’s not possible using the previous way due to confusing the springdata as a symbol.
A workaround is to use the set method from ext.

    set('springdata.commons', "2.0.9.RELEASE")

dependencies {
    compile "${property('springdata.commons')}"

Pay attention to the compile section since you are going to have the same problem there regarding your name, thus you need to use an expression.

The other way around is to use a file and add there your properties.


You compile section will be just the same.

dependencies {
    compile "${property('springdata.commons')}"

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.