DevOps / Gradle8 Interview Questions
How do you declare a dependency in Gradle?
Dependencies are declared inside the dependencies {} block, specifying a configuration and a coordinate in group:artifact:version form (or a project reference for a module in the same build):
dependencies { implementation 'org.apache.commons:commons-lang3:3.14.0' implementation project(':core') testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2' }
Gradle resolves external coordinates against whatever repositories are declared in the repositories {} block (commonly mavenCentral() or a private repository), downloading the artifact and its own transitive dependencies. In Gradle 8 projects using a version catalog, the same declaration instead references a catalog alias (e.g. implementation libs.commons.lang3), which centralizes the actual version number in one shared TOML file rather than repeating it inline across every module.
More Related questions...
