skip to content

What does the string dependency notation 'group:name:version' mean in Gradle, and how do you declare such a dependency?

level: juniorimportance: must knowfreq 80%

answer

  1. group:name:version = GAV
  2. colons delimit, dots don't
  3. passed to a configuration
  4. one colon = no version
  5. maps to Maven groupId/artifactId/version

basics

~10 s

It's the shorthand for a module's coordinates: group (org), name (artifact), version. You declare it inside a configuration, e.g. implementation("org.apache.commons:commons-lang3:3.14.0").

solid answer

~40 s

Gradle identifies an external module by three coordinates: **group** (the organization/namespace, like `org.springframework`), **name** (the artifact/module id, like `spring-core`), and **version**. The compact **string notation** packs them as `"group:name:version"`, passed to a configuration method such as `implementation`, `api`, or `testImplementation`. Gradle parses the colons, resolves the module from the declared repositories (Maven Central, etc.), downloads the artifact plus its transitive dependencies, and puts them on the relevant classpath. The version segment may be omitted (`"group:name"`) when something else — a platform/BOM or a dependency constraint — supplies it. In Kotlin DSL you call it as a function with parentheses; in Groovy DSL you can drop them. It's the most common form because it's terse and readable for the overwhelming majority of declarations.

code

kotlin · 6 lines
kotlin
dependencies {
    implementation("org.apache.commons:commons-lang3:3.14.0")
    // version omitted — a platform/BOM or constraint must supply it
    implementation("com.fasterxml.jackson.core:jackson-databind")
    testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
}

go deeper

for a junior

Recall that the three colon-separated parts are group, name, version, and that you put the string inside a configuration like implementation.

for a middle

Explain that it maps to Maven GAV, that the method is really add(configuration, notation), and that version can be omitted when a BOM/constraint supplies it.

for a senior

Discuss when you'd centralize versions (version catalogs, platforms) so declaration sites stay version-free, and the Kotlin-vs-Groovy DSL ergonomics.

for a principal

Frame coordinate hygiene at org scale: catalog/platform governance, banning inline versions, and how notation choices affect reproducibility and supply-chain auditing.

## What a dependency *is* in Gradle Gradle models a third-party library as a **module** identified by **GAV coordinates**: - **group** — the publishing organization namespace (e.g. `com.google.guava`). - **name** — the artifact/module name within that group (e.g. `guava`). - **version** — the released version (e.g. `33.0.0-jre`). These map directly onto Maven's `groupId` / `artifactId` / `version` and onto the directory layout in a Maven repository. ## The string notation The **string notation** is the colon-delimited shorthand `"group:name:version"`. You hand it to a *configuration* — a named bucket of dependencies — inside the `dependencies { }` block: ```kotlin dependencies { implementation("com.google.guava:guava:33.0.0-jre") testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") } ``` `implementation`, `api`, `testImplementation`, `runtimeOnly`, etc. are configuration names contributed by plugins (the `java`/`java-library` plugins create most of them). Each is really a call to `DependencyHandler.add(configurationName, notation)` — the DSL just gives you a method per configuration. ## Parsing rules - Exactly two colons → `group:name:version`. - One colon → `group:name` (no version); valid only when a constraint, platform/BOM, or `dependencyManagement` supplies the version. A version-less declaration with nothing supplying a version fails to resolve. - The `group` may itself contain dots (`org.apache.commons`) — only the **colons** delimit segments, not dots. ## DSL differences - **Kotlin DSL**: `implementation("g:n:v")` — it's a real function call, parentheses required. - **Groovy DSL**: `implementation 'g:n:v'` — parentheses optional, single quotes idiomatic. ## Why string notation dominates It's compact and reads like the coordinate it represents. You reach for the alternative **map notation** only when you need to attach a `classifier` or `ext`, or to express a segment programmatically. Functionally, `"g:n:v"` and `group: "g", name: "n", version: "v"` resolve identically.

  • Why might you declare a dependency with only `group:name` and no version?
    Because a platform/BOM (`platform(...)`) or a dependency constraint centralizes the version, so the declaration site stays version-free and versions are managed in one place.
  • Does the dot in `org.apache.commons` split the coordinate further?
    No. Only colons delimit the group/name/version segments; the dots are just part of the group string.

GAV is a postal address: group = city, name = street, version = house number. The string notation just writes that address on one line with colons between the parts.

saying these in an interview costs you the question

  • Claiming dots in the group split coordinates (only colons delimit).
  • Saying version is always mandatory in the string form — `group:name` is valid when a constraint/platform supplies the version.

context