Full stop(,), equals(=), space( ) and colons - when to use what with gradle


(Ian) #1

Hi,

New to gradle but one thing that has him me, some times i use a space

compile 'junit:junit:4+'

, sometimes a colon

apply plugin: 'java'

, sometimes an equal

runtimeClasspath=....

.

Obviously an equals is an assignment but what about the colon & the space - in the groovy world, what types/concepts are they?

Thanks,

Ian.


(sethgoings) #2

You should come up to speed with Groovy… a good reference is http://www.manning.com/koenig2/

The code snippets you pasted can be described as:

  1. a call to the compile function, passing in a string that is parsed by Gradle, using colons as delimiters for group/name/version. See related documentation here: http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html 2. a call to the apply function, where you’re passing in a map (key/value pairs). See related documentation here: http://www.gradle.org/docs/current/dsl/org.gradle.api.Project.html#org.gradle.api.Project:apply(java.util.Map) 3. setting a property “directly” on an underlying object. In Gradle land, whenever a “property” is listed, you interact with it in the “variable = value” construct. Sometimes there’s Groovy magic here (read up on http://groovy.codehaus.org/Groovy+Beans).