gradle 은 groovy 기반이다.


gradle에서 dependency lib를 정의할 때, 아래와 같이 single 또는 double quotation (', ")을 사용할 수 있다. 

(대부분의 spring 데모가 single quotation, '으로 정의하고 있다.)


compile 'org.scala-lang:scala-library:2.11.5'

compile "org.scala-lang:scala-library:2.11.5"



두 예시 모두 잘 동작한다.
그러나, 변수를 사용하려면 single quoation(')을 사용하면 컴파일시 이상하다고 에러가 발생한다. double quoation(")을 써야 변수명을 확인하고 컴파일을 할 수 있다. (고급 용어로 String interpolation 이라고 한다.)


scala-version = "2.11.7"
org.scala-lang:scala-library:${scala-version}"



참조 : groovy 문서 


http://docs.groovy-lang.org/latest/html/documentation/index.html#all-strings

String interpolation

Any Groovy expression can be interpolated in all string literals, apart from single and triple single quoted strings. Interpolation is the act of replacing a placeholder in the string with its value upon evaluation of the string. The placeholder expressions are surrounded by ${} or prefixed with $ for dotted expressions. The expression value inside the placeholder is evaluated to its string representation when the GString is passed to a method taking a String as argument by calling toString() on that expression.

Here, we have a string with a placeholder referencing a local variable:

def name = 'Guillaume' // a plain string
def greeting = "Hello ${name}"
 

assert greeting.toString() == 'Hello Guillaume'


Posted by '김용환'
,