कंपाइलर Gradle प्लग इन लिखें
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
Gradle का इस्तेमाल करने वाले लोग, Compose को आसानी से सेट अप और कॉन्फ़िगर करने के लिए, Compose Compiler Gradle प्लगिन का इस्तेमाल कर सकते हैं.
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 {
// Existing plugins
alias(libs.plugins.compose.compiler) apply false
}
- Compose का इस्तेमाल करने वाले हर मॉड्यूल में, प्लग इन लागू करें:
plugins {
// Existing plugins
alias(libs.plugins.compose.compiler)
}
अगर डिफ़ॉल्ट सेट अप का इस्तेमाल किया जा रहा है, तो अब आपका ऐप्लिकेशन बन जाना चाहिए और कंपाइल हो जाना चाहिए. अगर आपने Compose कंपाइलर पर कस्टम विकल्प कॉन्फ़िगर किए थे, तो नीचे दिया गया सेक्शन देखें.
Gradle वर्शन कैटलॉग के बिना सेट अप करना
वर्शन कैटलॉग के बिना Compose कंपाइलर Gradle प्लग इन सेट अप करने के लिए, Compose का इस्तेमाल करने वाले मॉड्यूल से जुड़ी build.gradle.kts
फ़ाइलों में यह प्लग इन जोड़ें:
plugins {
id("org.jetbrains.kotlin.plugin.compose") version "2.0.0" // this version matches your Kotlin version
}
Compose Compiler Gradle प्लग इन के साथ कॉन्फ़िगरेशन के विकल्प
Gradle प्लग इन का इस्तेमाल करके Compose कंपाइलर को कॉन्फ़िगर करने के लिए, सबसे ऊपर के लेवल पर मॉड्यूल की build.gradle.kts
फ़ाइल में composeCompiler
ब्लॉक जोड़ें.
android { … }
composeCompiler {
reportsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
}
उपलब्ध विकल्पों की पूरी सूची के लिए, दस्तावेज़ देखें.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","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 (UTC) को अपडेट किया गया."],[],[],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)."]]