Reputation: 3782
I've did web search for "gradle classpath site:stackoverflow.com" and "gradle classpath" and found relevant info in only:
Gradle: What is the difference between classpath and compile dependencies?
In the answer by Teng-pao Yu it is written:
compile 'org.hibernate:hibernate-core:5.0.5.Final' is a module dependency declaration. The compile configuration (which is now deprecated by the implementation configuration.) is merely a keyword for Implementation only dependencies. It is not a keyword describing which type of dependency it is (by type here I'm following the three types defined in the tutorial, i.e. module, file, and project.)
So as I understood classpath
is also keyword. I've tried to find its` meaning in gradle docs:
https://docs.gradle.org/current/userguide/declaring_dependencies.html
And some others referenced in it:
https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html
https://docs.gradle.org/current/userguide/java_library_plugin.html
https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.Configuration.html
https://docs.gradle.org/current/userguide/variant_model.html
https://docs.gradle.org/current/userguide/java_plugin.html
Also: https://docs.gradle.org/current/javadoc/org/gradle/api/initialization/dsl/ScriptHandler.html https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/Classpath.html https://docs.gradle.org/current/userguide/organizing_gradle_projects.html
There are mentions of 'compileClasspath'. If classpath
keyword is merely deprecated as compile
one, why is it absent from docs?
P.S. I mean like in:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
ADDED after answer:
search for getBuildscript() in gradle source code:
Upvotes: 1
Views: 6289
Reputation: 22952
So as I understood
classpath
is also keyword
This is incorrect. classpath
, compile
, implementation
, api
, and many more are all configurations. Configurations in Gradle are tree-like meaning typically each one extends from some parent:
For example, using the implementation
configuration, when you do the following in your build.gradle
:
dependencies {
implementation("org.apache.commons:commons-lang3:3.9")
}
You are actually doing:
project.getDependencies().add("implementation", "org.apache.commons:commons-lang3:3.9")
The former uses the Gradle DSL while the latter uses the Gradle API directly.
If
classpath
keyword is merely deprecated ascompile
one, why is it absent from docs?
The compile
configuration is deprecated as noted here. The classpath
configuration is still used, but typically only used with the buildscrpt { }
block.
So for your example:
buildscript {
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")
}
}
Desugars to:
project.getBuildscript().getDependencies().add("classpath", "com.android.tools.build:gradle:3.4.1")
Upvotes: 10