Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Version Catalogs

Status: 🟡 Partial — [catalog] parses and validates. Resolving a { catalog = … } reference is not implemented yet, so catalogs do not affect builds today. See Implementation Status.

A catalog declares versions once and lets every module reference them. It is the answer to five modules each pinning their own Ktor version and drifting apart.

Declaring one

In the workspace root Kargo.toml:

[workspace]
members = ["app", "shared", "server"]

[catalog.versions]
kotlin = "2.4.21"
coroutines = "1.8.0"
ktor = "2.3.0"

[catalog.libraries]
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", artifact = "kotlinx-coroutines-core", version.ref = "coroutines" }
ktor-server-core = { group = "io.ktor", artifact = "ktor-server-core", version.ref = "ktor" }
ktor-server-netty = { group = "io.ktor", artifact = "ktor-server-netty", version.ref = "ktor" }
ktor-client-core = { group = "io.ktor", artifact = "ktor-client-core", version.ref = "ktor" }

[catalog.bundles]
ktor-server = ["ktor-server-core", "ktor-server-netty"]

[catalog.plugins]
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
SectionHolds
[catalog.versions]Named version strings, referenced by version.ref
[catalog.libraries]Named coordinates
[catalog.bundles]Named groups of libraries added together
[catalog.plugins]Named compiler plugin ids

A library can pin its version inline with version = "2.3.0" instead of version.ref — the right choice for a one-off that no other entry shares.

Using it

# app/Kargo.toml
[dependencies]
kotlinx-coroutines = { catalog = "kotlinx-coroutines" }
ktor-server = { catalog = "ktor-server", bundle = true }

bundle = true says the name refers to a bundle, and pulls in every library it lists.

[plugins]
serialization = { catalog = "serialization" }

Upgrading

Change one line:

[catalog.versions]
ktor = "2.3.12"

Every module using ktor-* moves together. Compare with the alternative — four modules, three Ktor coordinates each, upgraded by search-and-replace and verified by hope.

kargo outdated          # checks catalog versions too
kargo update            # relocks against the new versions

When a catalog earns its keep

Project shapeVerdict
Single moduleSkip it. [dependencies] is already one place.
Two or three modulesOptional.
Four or more modules sharing librariesUse one. Drift is otherwise inevitable.
Any project where version mismatches have bitten youUse one.

A catalog in a single-module project adds indirection and removes nothing. The benefit is strictly about shared versions across modules.

Naming

Catalog names appear at every use site, so they repay a moment's thought.

# Good: a family prefix groups related entries together
ktor-server-core = { … }
ktor-server-netty = { … }
ktor-client-core = { … }

# Avoid: no grouping, and the name says nothing about what it is
server = { … }
netty-thing = { … }

Gradle interoperability

Status: ⚪ Planned.

Gradle's libs.versions.toml uses the same shape under different section names. Importing one directly is planned, so a migrating project can keep a single catalog while both build tools exist side by side:

[catalog]
import = "gradle/libs.versions.toml"

Until then, kargo migrate translating the file is the intended path — see Coming from Gradle.

Next