bilal_azam
bilal_azam

Reputation: 4800

Gradle syntax confusion

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
}

I know this is a dependencies task and it is a method which takes closure. I have concepts of closures but still I can understand what are these compile value. If I click on compile in gradle build.script it takes me to this Dependency add(String configurationName, Object dependencyNotation); function. Can you please explain this syntax ?

Upvotes: 1

Views: 183

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363825

It is an external dependency.

This is a dependency on some files built outside the current build, and stored in a repository of some kind, such as Maven central, or a corporate Maven or Ivy repository, or a directory in the local file system.

There are different notations supported for declaring a dependency on an external module:

 compile group: 'com.android.support', name: 'recyclerview-v7', version: '23.1.1'

or

compile 'com.android.support:recyclerview-v7:23.1.1'

The configurationName in this case is:

configurationName "group:name:version:classifier@extension"

or with a map notation:

configurationName group: group, name: name, version: version, classifier: classifier, ext: extension

More info here.

Upvotes: 1

Related Questions