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:
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")
thank you! I'm trying to find your last line in gradle source - see updated end of my question (picture from IDEA). Is it seen on the picture where that line is called? or should I search differently?
search for
getBuildscript().getDependencies()
return nothing and forgetDependencies()
returns 100+ entries so I hope to find code in question fromgetBuildscript()
entry.You aren't going to find 1:1 of the snippets I've added above. Gradle is heavily abstracted. Best bet to find the lines is to write a plugin that does the above and test/debug to trace the code paths.
I would also appreciate your help with stackoverflow.com/questions/60070739/…, start with added 2 at the end. That question was before I started to dig in and wrote this one. P.S. I wrote above before your response in comment. I guess answer (at least to ADDED 2) would be same?