Özel Depolar ve BOM'lar
Özel Maven veya Ivy depolarını yapılandırın ve tutarlı bağımlılık sürümleri için Malzeme Listelerini (BOM'lar) kullanın.
Özel Depolar ve BOM'lar, CoddyKit'te ücretsiz bir Groovy & Gradle: JVM Automation and Build Engineering dersidir. Bu, 4 dersinin 3. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Groovy & Gradle: JVM Automation and Build Engineering öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Groovy & Gradle: JVM Automation and Build Engineering kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Beyond Maven Central
By default, Gradle looks for dependencies in Maven Central. But what if your dependencies aren't there?
Custom repositories allow you to fetch libraries from other locations, like:
- Your company's private artifact server.
- Specific public repositories (e.g., Google's Maven repo for Android).
- Local file system directories.
Adding a Maven Repository
To add a custom Maven repository, you declare it in the repositories block of your build.gradle file.
Gradle will check repositories in the order they are declared, stopping at the first match.
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/milestone'
}
}Example: Google Maven Repo
Many Android libraries are hosted on Google's Maven repository. You'd add it like this:
This is crucial for projects using Google-specific libraries.
repositories {
google() // Shortcut for Google's Maven repo
mavenCentral()
}Understanding Ivy Repositories
While Maven is very common, Gradle also supports Ivy repositories. Ivy has a more flexible layout for artifacts.
You might encounter Ivy repositories in older projects or specific corporate environments.
repositories {
ivy {
url "http://repo.mycompany.com/ivy"
layout "pattern", {
artifact "[organization]/[module]/[revision]/[artifact](-[classifier])-[revision].[ext]"
}
}
}Local Directory as Repo
For testing or internal use, you can even use a local directory as a repository. This is handy for sharing artifacts within a team without a dedicated server.
Just specify the path to your local folder.
repositories {
flatDir {
dirs 'libs' // Looks for JARs directly in the 'libs' folder
}
// Or a more structured Maven-like local repo
maven {
url uri('../my-local-maven-repo')
}
}Bill of Materials (BOMs)
A Bill of Materials (BOM) is a special Maven POM file that defines a curated list of dependency versions.
It helps manage transitive dependencies and ensures consistent versions across a multi-module project or when using a suite of related libraries.
Consistency with BOMs
BOMs solve a common problem: dependency version conflicts. If multiple libraries depend on different versions of the same transitive dependency, you can end up with unpredictable behavior.
With a BOM, you declare a single "source of truth" for versions, making your build more reliable.
Importing a BOM
To use a BOM in Gradle, you declare it as a dependency using the platform() or enforcedPlatform() function. This tells Gradle to use the versions specified in the BOM.
Notice how we don't specify versions for spring-core or spring-web; the BOM handles it!
dependencies {
implementation platform('org.springframework.boot:spring-boot-dependencies:2.7.5')
// These versions are now managed by the BOM
implementation 'org.springframework:spring-core'
implementation 'org.springframework:spring-web'
}Platform vs. EnforcedPlatform
There are two ways to import a BOM:
platform(): Suggests versions. Other modules can override these versions if explicitly declared.enforcedPlatform(): Strictly enforces versions. Any explicitly declared versions for dependencies in the BOM will be overridden by the BOM's version.
Use enforcedPlatform() for strong version consistency.
Check Your Knowledge
Let's test your understanding of custom repositories and BOMs!
Custom Repos & BOMs Recap
Great job! You've learned how to:
- Configure custom Maven and Ivy repositories in Gradle.
- Understand the importance of repository order.
- Use local directories as repositories.
- Leverage Bill of Materials (BOMs) for consistent dependency version management.
- Differentiate between
platform()andenforcedPlatform().
These techniques are vital for managing complex dependency landscapes in real-world projects!
Yapay zeka eğitmeniyle Groovy öğren — ücretsiz
Tarayıcında gerçek kod yaz ve çalıştır, 7/24 yapay zeka eğitmeninden anında yardım al; web'de ya da uygulamada kaldığın yerden devam et.
- Kurslar
- 12
- Dersler
- 48
Sıkça Sorulan Sorular
“Özel Depolar ve BOM'lar” dersi ücretsiz mi?
Evet — “Özel Depolar ve BOM'lar” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Groovy & Gradle: JVM Automation and Build Engineering kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Groovy & Gradle: JVM Automation and Build Engineering kursu toplamda 4 dersten oluşur.
“Özel Depolar ve BOM'lar” dersinde ne öğreneceğim?
Özel Maven veya Ivy depolarını yapılandırın ve tutarlı bağımlılık sürümleri için Malzeme Listelerini (BOM'lar) kullanın. Groovy & Gradle: JVM Automation and Build Engineering ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Groovy & Gradle: JVM Automation and Build Engineering öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Groovy & Gradle: JVM Automation and Build Engineering, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 3. dersidir.
“Özel Depolar ve BOM'lar” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Groovy & Gradle: JVM Automation and Build Engineering dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Groovy & Gradle: JVM Automation and Build Engineering dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Proje Bağımlılıklarını Bildirme
- Bağımlılık Çözümleme ve Önbelleğe Alma
- Özel Depolar ve BOM'lar
- Sürüm Çakışmalarını ve Bağımlılık Kısıtlamalarını Çözme