3

What is the use of including classpath in dependencies section of buildscript build.gradle(Project). Example :

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

classpath 'com.android.tools.build:gradle:1.5.0' what is its purpose / what does it do?

Vipul Asri
  • 8,903
  • 3
  • 46
  • 71
  • It is to inform the project that I will be using this dependency. It like importing files into project. Hence, classpath defines the path of the dependency. – Bista Jan 12 '16 at 08:35
  • it use to updates the Android Plugin for Gradle to version 1.5.0. Refer http://developer.android.com/tools/revisions/gradle-plugin.html – Danh DC Jan 12 '16 at 08:38

1 Answers1

3

This is the classpath used by Gradle itself. If you want to extend your build logic with non-standard plugins or other supporting classes they must be found in this classpath.

The mentioned dependency com.android.tools.build:gradle:1.5.0 contains the plugin doing the android specific build stuff.

Henry
  • 42,982
  • 7
  • 68
  • 84
  • And I presume Gradle automatically downloads the [package](https://mvnrepository.com/artifact/com.android.tools.build/gradle) when it sees `classpath`, and then appends the path of the directory it downloaded to, to the [classpath](https://stackoverflow.com/questions/2396493/what-is-a-classpath-and-how-do-i-set-it). This is so that Gradle has access to these files when it runs (e.g. plugin files). When using `implementation`/ `api` in `app/build.gradle`, don't these dependencies also get added to the "classpath". So does it make sense to rename `classpath` to `gradleImplementation`. – Ben Butterworth Aug 11 '21 at 15:34