إنشاء مكوّن Gradle الإضافي لأداة التحويل البرمجي
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
بالنسبة إلى مستخدمي Gradle، يمكنك استخدام المكوّن الإضافي Gradle لـ Compose Compiler لتسهيل إعداد Compose وضبطه.
الإعداد باستخدام كتالوجات إصدارات Gradle
توضّح التعليمات التالية كيفية إعداد المكوّن الإضافي Compose Compiler
Gradle:
- في ملف
libs.versions.toml
، أزِل أي إشارة إلى مجمع Compose
.
- في قسم المكوّنات الإضافية، أضِف التبعية الجديدة التالية:
[versions]
kotlin = "2.0.0"
[plugins]
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
// Add this line
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
- في ملف
build.gradle.kts
الجذر لمشاريعك، أضِف ما يلي إلى القسم
plugins:
plugins {
// Existing plugins
alias(libs.plugins.compose.compiler) apply false
}
- في كل وحدة تستخدم Compose، طبِّق المكوِّن الإضافي:
plugins {
// Existing plugins
alias(libs.plugins.compose.compiler)
}
من المفترض أن يتم الآن إنشاء تطبيقك وتجميعه إذا كنت تستخدم الإعداد التلقائي. إذا
كنت قد أعددت خيارات مخصّصة في مُجمِّع Compose، اطّلِع على القسم التالي.
الإعداد بدون كتالوجات إصدارات Gradle
لإعداد المكوِّن الإضافي Gradle لـ Compose Compiler بدون كتالوجات الإصدارات، أضِف المكوِّن الإضافي التالي إلى ملفات build.gradle.kts
المرتبطة بالوحدات التي تستخدم
Compose:
plugins {
id("org.jetbrains.kotlin.plugin.compose") version "2.0.0" // this version matches your Kotlin version
}
خيارات الضبط باستخدام المكوّن الإضافي Gradle لـ Compose Compiler
لضبط مُجمِّع Compose باستخدام المكوِّن الإضافي Gradle، أضِف العنصر
composeCompiler
إلى ملف build.gradle.kts
للوحدة في أعلى
المستوى.
android { … }
composeCompiler {
reportsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
}
للاطّلاع على القائمة الكاملة للخيارات المتاحة، يُرجى الاطّلاع على المستندات.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Compose Compiler Gradle plugin\n\nFor Gradle users, you can use the Compose Compiler Gradle plugin to make setting\nup and configuring Compose easier.\n| **Note:** The Compose Compiler Gradle Plugin is only available from Kotlin 2.0+. For migration instructions, see [\"Jetpack Compose compiler moving to the Kotlin\n| repository\"](https://android-developers.googleblog.com/2024/04/jetpack-compose-compiler-moving-to-kotlin-repository.html). For an example migration, see the [Compose Samples\n| PR](https://github.com/android/compose-samples/pull/1354) in the Compose samples.\n\nSet up with Gradle version catalogs\n-----------------------------------\n\nThe following instructions outline how you can set up the Compose Compiler\nGradle plugin:\n\n1. In your `libs.versions.toml` file, remove any reference to the Compose compiler\n2. In the plugins section, add the following new dependency\n\n [versions]\n kotlin = \"2.0.0\"\n\n [plugins]\n org-jetbrains-kotlin-android = { id = \"org.jetbrains.kotlin.android\", version.ref = \"kotlin\" }\n\n // Add this line\n compose-compiler = { id = \"org.jetbrains.kotlin.plugin.compose\", version.ref = \"kotlin\" }\n\n1. In your projects root `build.gradle.kts` file, add the following to the plugins section:\n\n plugins {\n // Existing plugins\n alias(libs.plugins.compose.compiler) apply false\n }\n\n1. In each module that uses Compose, apply the plugin:\n\n plugins {\n // Existing plugins\n alias(libs.plugins.compose.compiler)\n }\n\nYour app should now build and compile if you are using the default set up. If\nyou had configured custom options on the Compose compiler, see the following\nsection.\n\nSet up without Gradle version catalogs\n--------------------------------------\n\nTo set up the Compose Compiler Gradle plugin without version catalogs, add the\nfollowing plugin to `build.gradle.kts` files associated with modules you use\nCompose: \n\n plugins {\n id(\"org.jetbrains.kotlin.plugin.compose\") version \"2.0.0\" // this version matches your Kotlin version\n }\n\nConfiguration options with the Compose Compiler Gradle Plugin\n-------------------------------------------------------------\n\nTo configure the Compose compiler using the Gradle plugin, add the\n`composeCompiler` block to the module's `build.gradle.kts` file at the top\nlevel. \n\n android { ... }\n\n composeCompiler {\n reportsDestination = layout.buildDirectory.dir(\"compose_compiler\")\n stabilityConfigurationFile = rootProject.layout.projectDirectory.file(\"stability_config.conf\")\n }\n\nFor the full list of available options, see the [documentation](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compiler.html#compose-compiler-options-dsl)."]]