Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do you need curly braces for variable substitution in Gradle?

If you have variables defined in your gradle.properties file, when is it necessary to use curly braces for variable substitution (e.g., "some string ${yourVariable}") and when is it okay to do without (e.g., "some string $yourVariable"). Is it considered best practice to always use curly braces?

like image 661
Michael Wu Avatar asked Nov 23 '15 20:11

Michael Wu


1 Answers

Is it considered best practice to always use curly braces?

Not necessarily. You can use curly braces all the time for consistency but I personally use them only when necessary.

Basically if any operation or method invocation is performed in interpolated expression you need to use curly braces. In all other cases it should just work. . operator also doesn't require to use curly braces unless you navigate the properties.

It would be much easier to view the docs. What's also important it's that it's rather groovy question, not gradle.

like image 69
Opal Avatar answered Sep 19 '22 17:09

Opal