2

Compare the:

compile 'org.apache.commons:commons-lang3:3.6'
compile "org.apache.commons:commons-lang3:3.6"

I used to use the '' in my build.gradle because it's simpler than "" and ("").

However I found the extra variables not work using '', for example,

Gradle is unable to resolve :

compile 'org.apache.commons:commons-lang3:$versions.commonsLang',

compile "org.apache.commons:commons-lang3:$versions.commonsLang" is working.

tim_yates
  • 167,322
  • 27
  • 342
  • 338
zhouji
  • 5,056
  • 1
  • 26
  • 26

2 Answers2

5

' (single quote) are used for standard java String whereas " (double quote) will be evaluated to GString if it has $ expression or to plain String it it hasn't.

Since gradle scripts (in this particular case) are written in groovy have a look at the docs also.

Opal
  • 81,889
  • 28
  • 189
  • 210
2

As you've noticed, " allows for variable interpolation / expansion inside the string, while ' does not. It is considered good practive to use ' if variable interpolation is not required, e.g. for performance reasons as the compiler does not need to parse the string for variable names then.

sschuberth
  • 28,386
  • 6
  • 101
  • 146