How to have gradle variable with a "-" dash/minus as dependencies version variable?

(kavin kankeshwar) #1

Can a gradle variable used in dependencies section have a “-” dash/minus in them, It looks like if i have a variable with “-” gradle cannot resolve dependencies and fails in the build step.

(Benjamin Muschko) #2

A dash represents an arithmetic operator in Java (and Groovy). That’s why you can’t use it when defining variables usually. However, you could probably define the variable as extra property:

ext.'spring-version' = '3.0'
println ext.'spring-version'

(Peter Niederwieser) #3

Using ‘ext’ when reading an extra property is problematic though. I would recommend to go with a simple and pragmatic solution, which is to use ‘_’ instead of ‘-’.

(kavin kankeshwar) #4

Thanks! i ended up using _.