Scrivio Interview library
CodingFoundations6 min read · updated 12 November 2026

What does a Gradle version catalog look like and how is it used from a build script?

A version catalog is a TOML file, by default gradle/libs.versions.toml, with four sections: [versions] for version numbers, [libraries] for dependency coordinates, [bundles] for groups of libraries, and [plugins] for plugin ids. Gradle turns it into a type-safe libs object, so a build script writes implementation(libs.jackson.databind) and plugins { alias(libs.plugins.spring.boot) } instead of repeating coordinates and versions. A catalog can also be published and shared across builds.

Why this question is asked

In a multi-module build, the same dependency is declared in many build files, and each copy can drift to a different version. Before catalogs, teams solved this with ext properties or constants in buildSrc, each in its own way. The version catalog is Gradle's standard answer, and it is now the first thing many teams set up in a new build. Interviewers ask this as a short coding question to see whether we have actually used it. In this answer, we will write a catalog section by section, use it from a build script, see how names become accessors, group libraries into bundles, and share the catalog with other builds.

1A Quick Recap: What a Catalog Is For

A version catalog is a list of the dependencies and plugins a build uses, with their coordinates and versions, kept in one file. Coordinates are the group, name and version that identify a library in a repository, such as com.fasterxml.jackson.core:jackson-databind:2.18.2.

The catalog does not add anything to a project by itself. It only defines names. A dependency is used only where a build script references it, which keeps each module's dependencies explicit while the versions live in one place. Gradle picks up gradle/libs.versions.toml automatically, with no extra configuration, and calls the catalog libs.

2Writing the Catalog File

Here is a catalog for a Spring Boot service. Each section has a specific job.

Properties
# gradle/libs.versions.toml
[versions]
jackson = "2.18.2"
springBoot = "3.5.0"
junit = "5.11.4"
[libraries]
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
jackson-datatype-jsr310 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "jackson" }
spring-boot-starter-web = { module = "org.springframework.boot:spring-boot-starter-web" } # version from the Boot BOM
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
postgresql = "org.postgresql:postgresql:42.7.4" # short form
[bundles]
jackson = ["jackson-databind", "jackson-datatype-jsr310"]
[plugins]
spring-boot = { id = "org.springframework.boot", version.ref = "springBoot" }
spring-dependency-management = { id = "io.spring.dependency-management", version = "1.1.7" }
The four sections
SectionHoldsUsed as
[versions]Named version numbersversion.ref in other sections, libs.versions.jackson
[libraries]Coordinates, with or without a versionimplementation(libs.jackson.databind)
[bundles]Lists of library aliasesimplementation(libs.bundles.jackson)
[plugins]Plugin ids and versionsalias(libs.plugins.spring.boot)

Notice version.ref: both Jackson libraries point at the same entry in [versions], so upgrading Jackson is a one-line change. A library may also have no version at all, like spring-boot-starter-web here, when a BOM or platform supplies it. The short string form is fine for a library whose version is used only once.

The [plugins] section works the same way for Gradle plugins, so plugin versions are kept with everything else instead of scattered across plugins blocks.

3Using It From a Build Script

In a build script, the catalog appears as libs. Dashes, underscores and dots in an alias become levels of the accessor, so jackson-databind becomes libs.jackson.databind.

Java
// app/build.gradle.kts
plugins {
java
alias(libs.plugins.spring.boot)
alias(libs.plugins.spring.dependency.management)
}
dependencies {
implementation(libs.spring.boot.starter.web)
implementation(libs.bundles.jackson) // adds jackson-databind and jackson-datatype-jsr310
runtimeOnly(libs.postgresql)
testImplementation(libs.junit.jupiter)
}
println(libs.versions.jackson.get()) // 2.18.2
// A typo is an error before anything runs:
// implementation(libs.jackson.datbind) // Unresolved reference 'datbind'

Notice that the accessors are type-safe: in the Kotlin DSL, a misspelled alias is a compile error, and the IDE completes the names. The alias() function in the plugins block applies a plugin with the id and version from the catalog. Versions are reachable through libs.versions, which helps when a plugin needs a version as a value, such as a tool version for Checkstyle.

4Bundles: Several Libraries in One Line

A bundle is just a named list of library aliases. Declaring implementation(libs.bundles.jackson) adds every library in the list to that configuration. It is useful for libraries that are always used together, such as Jackson's core module with its datatype modules, or a test bundle with JUnit, AssertJ and Mockito.

There is a limit to keep in mind: a bundle is added to one configuration as a whole. If a group needs some entries as implementation and others as runtimeOnly, it is not a good bundle. Bundles also have no versions of their own; each library keeps its own version from the catalog.

5Sharing a Catalog Across Builds

Within one build, every project sees the same libs. To share a catalog across repositories, a separate build publishes it as an artifact with the version-catalog plugin, and consumers import it in their settings.

Java
// catalog-repo/build.gradle.kts
plugins { `version-catalog`; `maven-publish` }
group = "com.myorg"; version = "2026.11.0"
catalog {
versionCatalog { from(files("gradle/libs.versions.toml")) }
}
publishing {
publications { create<MavenPublication>("catalog") { from(components["versionCatalog"]) } }
}
// settings.gradle.kts of a consuming build
dependencyResolutionManagement {
repositories { mavenCentral(); maven("https://repo.internal.example.com/releases") }
versionCatalogs {
create("myorg") { from("com.myorg:catalog:2026.11.0") }
}
}
// in build scripts: implementation(myorg.jackson.databind)

Notice the name myorg. If the consuming build also has its own gradle/libs.versions.toml, the name libs is already taken by it, so an imported catalog needs a different name. Upgrading the shared versions is then a single change in the consumer's settings, which update bots can propose automatically.

6Follow-up questions

Does a catalog force the versions of transitive dependencies?

No. A catalog only declares names and versions for the dependencies we reference. It does not take part in conflict resolution, so a transitive dependency still resolves by Gradle's normal rules. To align transitive versions, we use a platform, such as the Spring Boot BOM, which the catalog can itself declare as a library.

How do you declare a BOM in the catalog?

As a normal library entry, for example spring-boot-dependencies = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "springBoot" }, and then use it with implementation(platform(libs.spring.boot.dependencies)). The catalog supplies the coordinates; platform() makes Gradle treat it as a set of constraints.

Can I use a catalog in the Groovy DSL too?

Yes. The same libs object is available in Groovy scripts, with the same dotted names. Only the compile-time checking is weaker, since Groovy resolves names when the script runs.

7Conclusion

In this answer, we wrote a version catalog in gradle/libs.versions.toml with [versions], [libraries], [bundles] and [plugins] sections, used version.ref to share one version between libraries, and referenced entries from a build script as implementation(libs.jackson.databind), implementation(libs.bundles.jackson) and alias(libs.plugins.spring.boot). We saw that aliases become type-safe accessors, that bundles group libraries used together, and that a catalog can be published with the version-catalog plugin and imported under its own name in other builds.

What to say in the interviewAbout 80 seconds aloud

Open with

A version catalog is a TOML file, by default gradle/libs.versions.toml, that Gradle loads automatically and exposes as libs. It has four sections. versions holds named version numbers, like jackson equals 2.18.2. libraries holds coordinates, for example jackson-databind equals module com.fasterxml.jackson.core:jackson-databind with version.ref jackson, so several libraries can share one version, or no version at all when a BOM supplies it. bundles groups aliases that are used together, like jackson-databind and the JSR-310 module.

Then, if they want more

And plugins holds plugin ids and versions, like spring-boot with id org.springframework.boot. In a build script I write implementation(libs.jackson.databind); dashes in the alias become dots in the accessor. implementation(libs.bundles.jackson) adds the whole bundle, and in the plugins block alias(libs.plugins.spring.boot) applies the plugin with the catalog's version.

In the Kotlin DSL these are type-safe, so a typo is a compile error and the IDE completes names. Upgrading Jackson becomes a one-line change in one file. Catalogs can also be shared: a separate build publishes one with the version-catalog plugin, and other builds import it in settings under a name like myorg.

One thing I always point out is that a catalog only declares names; it does not align transitive versions. That is what a platform such as the Spring Boot BOM does.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Gradle user manual
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What does a Gradle version catalog look like and how is it used from a build script?": https://scrivio-interview-library.netlify.app/java/gradle/37ce01caa6/