0Pricing
Kotlin Multiplatform Academy · Lektion

maven-publish für KMP konfigurieren

Veröffentlichen Sie alle Target-Artefakte sowie das Metadatenmodul.

maven-publish für KMP konfigurieren ist eine kostenlose Kotlin Multiplatform Academy-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Kotlin Multiplatform Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Kotlin Multiplatform Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

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:publish

Add 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:publishToMavenLocal

Sources 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. 🎉

Häufig gestellte Fragen

Ist die Lektion „maven-publish für KMP konfigurieren“ kostenlos?

Ja — der vollständige Text von „maven-publish für KMP konfigurieren“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Kotlin Multiplatform Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Kotlin Multiplatform Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „maven-publish für KMP konfigurieren“?

Veröffentlichen Sie alle Target-Artefakte sowie das Metadatenmodul. Du übst Kotlin Multiplatform Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Kotlin Multiplatform Academy zu starten?

Keine Vorkenntnisse erforderlich. Kotlin Multiplatform Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.

Wie lange dauert die Lektion „maven-publish für KMP konfigurieren“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Kotlin Multiplatform Academy-Lektion Code schreiben und ausführen?

Ja. Jede Kotlin Multiplatform Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. maven-publish für KMP konfigurieren
  2. Ein XCFramework für iOS ausliefern
  3. Versionierung und API-Stabilität
  4. Auf Maven Central und SPM veröffentlichen
← Zurück zu Kotlin Multiplatform Academy