Gradle
https://docs.gradle.org/current/userguide/userguide_single.html
Last updated
Was this helpful?
https://docs.gradle.org/current/userguide/userguide_single.html
Last updated
Was this helpful?
Configuration is a named set of dependencies grouped together as a specific goal.
the source files and where they’re located
the compilation classpath, including any required dependencies (via Gradle )
where the compiled class files are placed
sourceSet is a placeholder (for main source set it is default)
Repository => e.g. mavenCentral()
Configuration => e.g. implementation
Module coordinate => '<groupId>:<artifactId>:<version>'
Every dependency declared for a Gradle project applies to a specific scope. Many Gradle plugins add pre-defined configurations to your project.
Child configurations inherit the whole set of dependencies declared for any of its superconfigurations.
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.
Configurations have at least 3 different roles:
to declare dependencies
as a consumer, to resolve a set of dependencies to files
api - both a compile and runtime dependency on this artifact
implementation - only a runtime dependency on this artifact
src/main/java
src/main/resources
src/test/java
src/test/resources
src/
sourceSet
/java
src/
sourceSet
/resources
Gray text — the configuration is deprecated.
Green background — you can declare dependencies against the configuration.
Blue-gray background — the configuration is for consumption by tasks, not for you to declare dependencies.
Light blue background with monospace text — a task.
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.
During the configuration phase, Gradle finds the build script(s) in the root and subproject directories.
Under the covers the testImplementation
and implementation
configurations form an inheritance hierarchy by calling the method
as a producer, to expose artifacts and their dependencies for consumption by other projects (such consumable configurations usually represent the the producer offers to its consumers)
Great article about which kind of modules can exist in the application.
Visualise modules.
When a build script, build.gradle(.kts)
, is found, Gradle configures a object.
The purpose of the object is to create a collection of objects, apply plugins, and retrieve dependencies.