Konfiguracja maven-publish dla KMP
Publikuj artefakty wszystkich celów oraz moduł metadanych.
Konfiguracja maven-publish dla KMP to bezpłatna lekcja Kotlin Multiplatform Academy na CoddyKit. To lekcja 1 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 Kotlin Multiplatform Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Kotlin Multiplatform Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
Why Publish at All
Once your shared module is solid, other teams want to reuse it. Publishing turns your code into a versioned artifact they can simply depend on. 📦
Meet maven-publish
The maven-publish Gradle plugin packages your build outputs into artifacts and writes the metadata repositories expect.
plugins {
kotlin("multiplatform")
id("maven-publish")
}KMP Publishes Many Artifacts
A KMP library is not one JAR. Each target gets its own artifact, plus a shared metadata module that ties them together.
The Root Metadata Module
The metadata module is the entry point consumers actually request. Gradle then resolves the right per-platform artifact behind it.
Coordinates Identify You
Every artifact needs coordinates: a group, an artifact name, and a version. Together they form the unique address others depend on.
group = "com.coddykit.shared"
version = "1.0.0"Declare a Repository
Tell Gradle where artifacts go using a publishing block. A local folder is perfect for testing before any remote release.
publishing {
repositories {
maven { url = uri(layout.buildDirectory.dir("repo")) }
}
}Run the Publish Task
The plugin adds Gradle tasks for you. Running publish builds every target and copies all artifacts into your chosen repository.
./gradlew :shared:publishAdd POM Metadata
The POM describes your library: name, description, and license. Public repositories require this so users know what they are pulling in.
pom {
name.set("Shared KMP")
description.set("Shared logic for both apps")
}Test Locally First
Publish to your mavenLocal cache, then add it as a dependency in a sample app. This proves the artifact resolves before you go public.
./gradlew :shared:publishToMavenLocalSources and Docs Jars
Ship a sources jar so consumers can read your code in their IDE. A docs jar adds the generated reference for an even better experience.
Keep Versions Honest
Bump the version on every release. Republishing the same version with new code breaks builds that already cached the old artifact.
Quick Check
Let's check how KMP publishing works.
Recap
Apply maven-publish, set coordinates, add a repository and POM, then publish locally to test before any real release. 🎉
Często zadawane pytania
Czy lekcja „Konfiguracja maven-publish dla KMP” jest bezpłatna?
Tak — pełny tekst „Konfiguracja maven-publish dla KMP” 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 Kotlin Multiplatform Academy, przejdź na CoddyKit PRO. Kurs Kotlin Multiplatform Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Konfiguracja maven-publish dla KMP”?
Publikuj artefakty wszystkich celów oraz moduł metadanych. Ćwiczysz Kotlin Multiplatform Academy 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ąć Kotlin Multiplatform Academy?
Nie wymagamy żadnego doświadczenia. Kotlin Multiplatform Academy 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 1 z 4.
Ile czasu zajmuje lekcja „Konfiguracja maven-publish dla KMP”?
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 Kotlin Multiplatform Academy?
Tak. Każda lekcja Kotlin Multiplatform Academy 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
- Konfiguracja maven-publish dla KMP
- Dostarczanie XCFramework dla iOS
- Wersjonowanie i stabilność API
- Publikowanie w Maven Central i SPM