Katalogi wersji zależności i platformy
Centralizuj i wymuszaj wersje zależności w dużej, wielomodułowej kompilacji za pomocą katalogów wersji i platform Gradle (BOM), zapewniając spójność i kontrolę.
Katalogi wersji zależności i platformy to bezpłatna lekcja Groovy & Gradle: JVM Automation and Build Engineering na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Groovy & Gradle: JVM Automation and Build Engineering, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Groovy & Gradle: JVM Automation and Build Engineering zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
The Version Drift Problem
In enterprise builds with dozens of modules, the same library can end up declared with different versions, causing subtle runtime conflicts. Centralizing versions prevents this drift.
What is a Version Catalog?
A version catalog is a single typesafe list of dependencies and versions, defined in gradle/libs.versions.toml and shared across all modules.
The TOML Format
The catalog has sections for versions, libraries, and plugins.
[versions]
guava = "33.0.0-jre"
[libraries]
guava = { module = "com.google.guava:guava", version.ref = "guava" }Using Catalog Entries
In a build script you reference the typesafe accessor, getting IDE completion and a compile error if the name is wrong.
dependencies {
implementation(libs.guava)
}Bundles
Group related libraries into a bundle so modules add them all at once.
[bundles]
networking = ["retrofit", "okhttp"]Plugin Versions in the Catalog
Catalogs can also pin plugin versions, keeping the whole toolchain consistent.
[plugins]
spring = { id = "org.springframework.boot", version = "3.2.0" }What is a Platform?
A platform (Maven BOM) constrains versions of transitive dependencies without adding them. It governs what version wins during resolution.
Applying a Platform
Import a BOM with the platform() notation; aligned dependencies inherit its managed versions.
dependencies {
implementation(platform("org.springframework.boot:spring-boot-dependencies:3.2.0"))
implementation("org.springframework:spring-web")
}Publishing Your Own Platform
Large orgs publish an internal platform module so every team aligns on approved versions automatically.
plugins { id("java-platform") }
dependencies {
constraints {
api("com.acme:logging:2.1.0")
}
}Catalog vs Platform
They complement each other:
- Catalog: what you type when declaring dependencies
- Platform: which transitive versions are allowed at resolution
Governance Benefits
Together they give central teams control: upgrade a library once, and every module follows, with reviewable changes in version control.
Quick Check
Test your understanding of catalogs and platforms.
Recap
You learned centralized version management:
- Catalog in
libs.versions.tomlgives typesafe accessors - Bundles group related libraries
- Platforms (BOMs) constrain transitive versions
- Together they enforce consistency across large builds
Często zadawane pytania
Czy lekcja „Katalogi wersji zależności i platformy” jest bezpłatna?
Tak — pełny tekst „Katalogi wersji zależności i platformy” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Groovy & Gradle: JVM Automation and Build Engineering, przejdź na CoddyKit PRO. Kurs Groovy & Gradle: JVM Automation and Build Engineering zawiera 4 lekcji w sumie.
Co nauczysz się w „Katalogi wersji zależności i platformy”?
Centralizuj i wymuszaj wersje zależności w dużej, wielomodułowej kompilacji za pomocą katalogów wersji i platform Gradle (BOM), zapewniając spójność i kontrolę. Ćwiczysz Groovy & Gradle: JVM Automation and Build Engineering z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Groovy & Gradle: JVM Automation and Build Engineering?
Nie wymagamy żadnego doświadczenia. Groovy & Gradle: JVM Automation and Build Engineering w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.
Ile czasu zajmuje lekcja „Katalogi wersji zależności i platformy”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Groovy & Gradle: JVM Automation and Build Engineering?
Tak. Każda lekcja Groovy & Gradle: JVM Automation and Build Engineering zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Gradle Build Scans i analizy
- Bezpieczeństwo i zarządzanie poświadczeniami
- Wtyczki konwencji i logika kompilacji
- Katalogi wersji zależności i platformy