|
|
@ -7,12 +7,15 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.jetbrains.compose |
|
|
|
package org.jetbrains.compose |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import groovy.lang.Closure |
|
|
|
import org.gradle.api.Plugin |
|
|
|
import org.gradle.api.Plugin |
|
|
|
import org.gradle.api.Project |
|
|
|
import org.gradle.api.Project |
|
|
|
import org.gradle.api.artifacts.ComponentMetadataContext |
|
|
|
import org.gradle.api.artifacts.ComponentMetadataContext |
|
|
|
import org.gradle.api.artifacts.ComponentMetadataRule |
|
|
|
import org.gradle.api.artifacts.ComponentMetadataRule |
|
|
|
import org.gradle.api.artifacts.dsl.ComponentModuleMetadataHandler |
|
|
|
import org.gradle.api.artifacts.dsl.ComponentModuleMetadataHandler |
|
|
|
import org.gradle.api.artifacts.dsl.DependencyHandler |
|
|
|
import org.gradle.api.artifacts.dsl.DependencyHandler |
|
|
|
|
|
|
|
import org.gradle.api.artifacts.dsl.RepositoryHandler |
|
|
|
|
|
|
|
import org.gradle.api.artifacts.repositories.MavenArtifactRepository |
|
|
|
import org.gradle.api.plugins.ExtensionAware |
|
|
|
import org.gradle.api.plugins.ExtensionAware |
|
|
|
import org.jetbrains.compose.android.AndroidExtension |
|
|
|
import org.jetbrains.compose.android.AndroidExtension |
|
|
|
import org.jetbrains.compose.desktop.DesktopExtension |
|
|
|
import org.jetbrains.compose.desktop.DesktopExtension |
|
|
@ -32,13 +35,7 @@ class ComposePlugin : Plugin<Project> { |
|
|
|
val androidExtension = composeExtension.extensions.create("android", AndroidExtension::class.java) |
|
|
|
val androidExtension = composeExtension.extensions.create("android", AndroidExtension::class.java) |
|
|
|
|
|
|
|
|
|
|
|
if (!project.buildFile.endsWith(".gradle.kts")) { |
|
|
|
if (!project.buildFile.endsWith(".gradle.kts")) { |
|
|
|
// add compose extension for Groovy DSL to work |
|
|
|
setUpGroovyDslExtensions(project) |
|
|
|
project.dependencies.extensions.add("compose", Dependencies) |
|
|
|
|
|
|
|
project.plugins.withId("org.jetbrains.kotlin.multiplatform") { |
|
|
|
|
|
|
|
(project.extensions.getByName("kotlin") as? ExtensionAware)?.apply { |
|
|
|
|
|
|
|
extensions.add("compose", Dependencies) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
project.initializePreview() |
|
|
|
project.initializePreview() |
|
|
@ -211,6 +208,9 @@ class ComposePlugin : Plugin<Project> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun RepositoryHandler.jetbrainsCompose(): MavenArtifactRepository = |
|
|
|
|
|
|
|
maven { repo -> repo.setUrl("https://maven.pkg.jetbrains.space/public/p/compose/dev") } |
|
|
|
|
|
|
|
|
|
|
|
fun KotlinDependencyHandler.compose(groupWithArtifact: String) = composeDependency(groupWithArtifact) |
|
|
|
fun KotlinDependencyHandler.compose(groupWithArtifact: String) = composeDependency(groupWithArtifact) |
|
|
|
val KotlinDependencyHandler.compose get() = ComposePlugin.Dependencies |
|
|
|
val KotlinDependencyHandler.compose get() = ComposePlugin.Dependencies |
|
|
|
|
|
|
|
|
|
|
@ -218,3 +218,19 @@ fun DependencyHandler.compose(groupWithArtifact: String) = composeDependency(gro |
|
|
|
val DependencyHandler.compose get() = ComposePlugin.Dependencies |
|
|
|
val DependencyHandler.compose get() = ComposePlugin.Dependencies |
|
|
|
|
|
|
|
|
|
|
|
private fun composeDependency(groupWithArtifact: String) = "$groupWithArtifact:$composeVersion" |
|
|
|
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) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
(project.repositories as? ExtensionAware)?.extensions?.apply { |
|
|
|
|
|
|
|
add("jetbrainsCompose", object : Closure<MavenArtifactRepository>(project.repositories) { |
|
|
|
|
|
|
|
fun doCall(): MavenArtifactRepository = |
|
|
|
|
|
|
|
project.repositories.jetbrainsCompose() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|