Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I include odd characters in Groovy variable names?

I am migrating from Maven3 to Gradle and I have an dependency on an internal project that includes some properties as version identifiers. When I try to compile my project, it complains about the dependency not found. The problem is these properties either use a period '.' or a dash '-' (e.g., cargo.version, supported-spring-version).

Is there a way in Groovy to declare a variable with odd characters?

def 'supported-spring-version' = '3.1.0.RELEASE'

like image 660
Kevin Avatar asked Sep 17 '12 20:09

Kevin


1 Answers

You can't use def, but you can declare them in the current binding

this.'some-string' = '3'

println​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ this.'some-string'​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

There's probably a better way round this though, but there's not enough information in your question to reliably suggest an alternative

like image 59
tim_yates Avatar answered Nov 15 '22 04:11

tim_yates