kotlinforandroid
01/06/2024, 12:54 PMbuild-logic
that applies the Jetbrains Compose libraries. But trying it this way results in an error. There is no KotlinMultiplatformExtension#compose
property available.
class KmpComposePlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("kmp")
apply("org.jetbrains.compose")
}
val extension = extensions.getByType<KotlinMultiplatformExtension>()
with(extension) {
jvm()
sourceSets.commonMain.dependencies {
implementation(this@with.compose.runtime)
}
}
}
}
}
Chrimaeon
01/06/2024, 1:06 PMconfigure
the extenstion. at this point in time where you are trying to access it, its not “applied”.
import org.gradle.kotlin.dsl.configure
extensions.configure<KotlinMultiplatformExtension>{}
Chrimaeon
01/06/2024, 1:12 PMkotlinforandroid
01/06/2024, 2:05 PMconfigure
the extenstion. at this point in time where you are trying to access it, its not “applied”.
I changed the code to this but it still doesn't detect it. Is that what you meant by configuring? The compose property is still not accessible within my custom plugin.
extensions.configure<KotlinMultiplatformExtension> {
jvm()
sourceSets.commonMain.dependencies {
implementation(compose.runtime)
}
}
hfhbd
01/06/2024, 3:36 PMChrimaeon
01/06/2024, 3:39 PMapply(“kmp”)
That’s not the kotlin Multiplattform plug-in 🤔hfhbd
01/06/2024, 3:41 PMVaibhav Jaiswal
01/06/2024, 4:46 PMval composeDeps = extensions.getByType<ComposeExtension>().dependencies
And then you can apply it like
implementation(composeDeps.runtime)
kotlinforandroid
01/06/2024, 6:52 PMComposeExtension
.
For people stumbling across this: kmp
is the ID of my custom plugin above.Bekzod
01/07/2024, 4:32 PMplugins *{*
``kotlin-dsl``
}
_group_ = "uz.uzkassa.buildlogic"
_java_ *{*
_sourceCompatibility_ = JavaVersion._VERSION_1_8_
targetCompatibility = JavaVersion._VERSION_1_8_
}
_dependencies_ *{*
_compileOnly_(_libs_._android_._gradlePlugin_)
_compileOnly_(_libs_._kotlin_._gradlePlugin_)
}
_gradlePlugin_ *{*
plugins *{*
register("androidApplicationCompose")*{*
_id_ = "horeca.compose"
_implementationClass_ = "ComposeMultiplatformConventionPlugin"
}
register("androidApplication")*{*
_id_ = "horeca.feature"
_implementationClass_ = "FeatureMultiplatformConventionPlugin"
}
register("androidLibrary") *{*
_id_ = "horeca.android.library"
_implementationClass_ = "TEST_AndroidLibraryConventionPlugin"
}
}
}
kotlinforandroid
01/08/2024, 12:52 AMval compose = extensions.getByType<ComposeExtension>().dependencies
extensions.configure<KotlinMultiplatformExtension> {
jvm()
sourceSets.commonMain.dependencies {
implementation(compose.material3)
implementation(compose.materialIconsExtended)
implementation(compose.runtime)
implementation(compose.ui)
}
}
Vaibhav Jaiswal
01/08/2024, 3:45 AMcompileOnly
dependency
compose-gradlePlugin = { module = "org.jetbrains.compose:org.jetbrains.compose.gradle.plugin", version.ref = "compose" }
Bekzod
01/08/2024, 7:09 AMbuild-logic->convention->build.gradle.kts plugins{alias(_libs_._plugins_._jetbrainsCompose)_}
but it throw exception by asking other compose related configuration. I'm new to KMM, so struggling to set up.Vaibhav Jaiswal
01/08/2024, 7:10 AMdependencies
block as compileOnly(libs.plugins.jetbrainsCompose