تهيئة maven-publish لـ KMP
انشر جميع ملفات الأهداف ووحدة البيانات الوصفية.
تهيئة maven-publish لـ KMP درس مجاني في Kotlin Multiplatform Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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. 🎉
الأسئلة الشائعة
هل درس «تهيئة maven-publish لـ KMP» مجاني؟
نعم — نص درس «تهيئة maven-publish لـ KMP» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Kotlin Multiplatform Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Kotlin Multiplatform Academy 4 دروس في المجموع.
ماذا ستتعلم في «تهيئة maven-publish لـ KMP»؟
انشر جميع ملفات الأهداف ووحدة البيانات الوصفية. تتمرن على Kotlin Multiplatform Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Kotlin Multiplatform Academy؟
لا تُشترط خبرة سابقة. Kotlin Multiplatform Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «تهيئة maven-publish لـ KMP»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Kotlin Multiplatform Academy هذا؟
نعم. كل درس في Kotlin Multiplatform Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- تهيئة maven-publish لـ KMP
- إصدار XCFramework لـ iOS
- إدارة الإصدارات واستقرار API
- الإصدار إلى Maven Central وSPM