0Pricing
Kotlin Multiplatform Academy · Lesson

Configure maven-publish for KMP

Publish all target artifacts and the metadata module.

Configure maven-publish for KMP is a free Kotlin Multiplatform Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Multiplatform Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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

Frequently asked questions

Is the “Configure maven-publish for KMP” lesson free?

Yes — the full text of “Configure maven-publish for KMP” is free to read here on the web, and the Kotlin Multiplatform Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Multiplatform Academy course, upgrade to CoddyKit PRO.

What will I learn in “Configure maven-publish for KMP”?

Publish all target artifacts and the metadata module. You practise Kotlin Multiplatform Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Kotlin Multiplatform Academy?

No prior experience is required. Kotlin Multiplatform Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Configure maven-publish for KMP” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Kotlin Multiplatform Academy lesson?

Yes. Every Kotlin Multiplatform Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Configure maven-publish for KMP
  2. Ship an XCFramework for iOS
  3. Versioning & API Stability
  4. Release to Maven Central & SPM
← Back to Kotlin Multiplatform Academy