Browse Source

gradle-plugin: Let Gradle provide its Kotlin DSL for compose (#2215)

pull/2347/head
Omico 2 years ago committed by GitHub
parent
commit
99b7a986e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt

6
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt

@ -39,6 +39,8 @@ class ComposePlugin : Plugin<Project> {
val androidExtension = composeExtension.extensions.create("android", AndroidExtension::class.java)
val experimentalExtension = composeExtension.extensions.create("experimental", ExperimentalExtension::class.java)
project.dependencies.extensions.add("compose", Dependencies)
if (!project.buildFile.endsWith(".gradle.kts")) {
setUpGroovyDslExtensions(project)
}
@ -220,16 +222,12 @@ fun RepositoryHandler.jetbrainsCompose(): MavenArtifactRepository =
maven { repo -> repo.setUrl("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
fun KotlinDependencyHandler.compose(groupWithArtifact: String) = composeDependency(groupWithArtifact)
val KotlinDependencyHandler.compose get() = ComposePlugin.Dependencies
fun DependencyHandler.compose(groupWithArtifact: String) = composeDependency(groupWithArtifact)
val DependencyHandler.compose get() = ComposePlugin.Dependencies
private fun composeDependency(groupWithArtifact: String) = "$groupWithArtifact:$composeVersion"
private fun setUpGroovyDslExtensions(project: Project) {
// add compose extension for Groovy DSL to work
project.dependencies.extensions.add("compose", ComposePlugin.Dependencies)
project.plugins.withId("org.jetbrains.kotlin.multiplatform") {
(project.extensions.getByName("kotlin") as? ExtensionAware)?.apply {
extensions.add("compose", ComposePlugin.Dependencies)

Loading…
Cancel
Save