Let’s say you wanted to write a suite of smoke tests. Each smoke test makes a HTTP call to verify a web service endpoint. As the underlying test framework the project already uses JUnit. You can define a new configuration named smokeTest that extends from the testImplementation configuration to reuse the existing test framework dependency.
as a consumer, to resolve a set of dependencies to files
as a producer, to expose artifacts and their dependencies for consumption by other projects (such consumable configurations usually represent the variants the producer offers to its consumers)
Api vs Implementation
api - both a compile and runtime dependency on this artifact
implementation - only a runtime dependency on this artifact
key difference between "subprojects" and "allprojects" is that "subprojects" only applies the settings to the direct subprojects of the current project, while "allprojects" applies the settings to the current project and all of its subprojects.
Build lifecycle
During the configuration phase, Gradle finds the build script(s) in the root and subproject directories.
When a build script, build.gradle(.kts), is found, Gradle configures a Project object.
The purpose of theProject object is to create a collection of Task objects, apply plugins, and retrieve dependencies.
configurations {
// declare a "configuration" named "someConfiguration"
// it doesn’t tell us how the configuration is meant to be used
someConfiguration
}
dependencies {
// add a project dependency to the "someConfiguration" configuration
someConfiguration project(":lib")
}
configurations {
// declare a configuration that is going to resolve the compile classpath of the application
compileClasspath.extendsFrom(someConfiguration)
// declare a configuration that is going to resolve the runtime classpath of the application
runtimeClasspath.extendsFrom(someConfiguration)
}