KMP向けにmaven-publishを設定する
すべてのターゲット成果物とメタデータモジュールを公開します
「KMP向けにmaven-publishを設定する」はCoddyKit上の無料Kotlin Multiplatform Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはKotlin Multiplatform Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Kotlin Multiplatform Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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. 🎉
よくある質問
「KMP向けにmaven-publishを設定する」レッスンは無料ですか?
はい。「KMP向けにmaven-publishを設定する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Kotlin Multiplatform Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Kotlin Multiplatform Academyコースには全4レッスンが含まれています。
「KMP向けにmaven-publishを設定する」で何を学びますか?
すべてのターゲット成果物とメタデータモジュールを公開します ブラウザで直接実行するハンズオンコードでKotlin Multiplatform Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Kotlin Multiplatform Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのKotlin Multiplatform Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。
「KMP向けにmaven-publishを設定する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このKotlin Multiplatform Academyレッスンでコードを書いて実行できますか?
はい。すべてのKotlin Multiplatform Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- KMP向けにmaven-publishを設定する
- iOS向けXCFrameworkを出荷する
- バージョン管理とAPIの安定性
- Maven CentralとSPMにリリースする