Browse Source

Split Maven artifact configuration and Gradle plugin configuration

This is needed to introduce non-Gradle plugin modules under gradle-plugins build for
Compose preview runtime.
pull/566/head
Alexey Tsvetkov 4 years ago committed by Alexey Tsvetkov
parent
commit
6dbe467abf
  1. 33
      gradle-plugins/build.gradle.kts
  2. 3
      gradle-plugins/buildSrc/src/main/kotlin/GradlePluginConfigExtension.kt
  3. 14
      gradle-plugins/buildSrc/src/main/kotlin/MavenPublicationConfigExtension.kt
  4. 9
      gradle-plugins/compose/build.gradle.kts

33
gradle-plugins/build.gradle.kts

@ -48,20 +48,28 @@ subprojects {
}
afterEvaluate {
gradlePluginConfig?.let { configureGradlePlugin(it) }
mavenPublicationConfig?.let { mavenPublicationConfig ->
configurePublication(mavenPublicationConfig)
gradlePluginConfig?.let { gradlePluginConfig ->
configureGradlePlugin(mavenPublicationConfig, gradlePluginConfig)
}
}
}
}
fun Project.configureGradlePlugin(config: GradlePluginConfigExtension) {
fun Project.configurePublication(
publicationConfig: MavenPublicationConfigExtension
) {
// maven publication for plugin
configureIfExists<PublishingExtension> {
// pluginMaven is a default publication created by java-gradle-plugin
// https://github.com/gradle/gradle/issues/10384
publications.create<MavenPublication>("pluginMaven") {
artifactId = config.artifactId
artifactId = publicationConfig.artifactId
pom {
name.set(config.displayName)
description.set(config.description)
name.set(publicationConfig.displayName)
description.set(publicationConfig.description)
url.set(BuildProperties.website)
licenses {
license {
@ -72,22 +80,27 @@ fun Project.configureGradlePlugin(config: GradlePluginConfigExtension) {
}
}
}
}
fun Project.configureGradlePlugin(
publicationConfig: MavenPublicationConfigExtension,
gradlePluginConfig: GradlePluginConfigExtension
) {
// metadata for gradle plugin portal (relates to pluginBundle extension block from com.gradle.plugin-publish)
configureIfExists<PluginBundleExtension> {
vcsUrl = BuildProperties.vcs
website = BuildProperties.website
description = config.description
description = publicationConfig.description
}
// gradle plugin definition (relates to gradlePlugin extension block from java-gradle-plugin)
configureIfExists<GradlePluginDevelopmentExtension> {
plugins {
create("gradlePlugin") {
id = config.pluginId
displayName = config.displayName
description = config.description
implementationClass = config.implementationClass
id = gradlePluginConfig.pluginId
displayName = publicationConfig.displayName
description = publicationConfig.description
implementationClass = gradlePluginConfig.implementationClass
version = project.version
}
}

3
gradle-plugins/buildSrc/src/main/kotlin/GradlePluginConfigExtension.kt

@ -8,10 +8,7 @@ import org.gradle.api.Project
// Plugin-specific properties (also see gradle-plugins/build.gradle.kts)
open class GradlePluginConfigExtension {
lateinit var pluginId: String
lateinit var artifactId: String
lateinit var implementationClass: String
lateinit var displayName: String
lateinit var description: String
}
val Project.gradlePluginConfig: GradlePluginConfigExtension?

14
gradle-plugins/buildSrc/src/main/kotlin/MavenPublicationConfigExtension.kt

@ -0,0 +1,14 @@
import org.gradle.api.Project
open class MavenPublicationConfigExtension {
lateinit var artifactId: String
lateinit var displayName: String
lateinit var description: String
}
val Project.mavenPublicationConfig: MavenPublicationConfigExtension?
get() = extensions.findByType(MavenPublicationConfigExtension::class.java)
fun Project.mavenPublicationConfig(fn: MavenPublicationConfigExtension.() -> Unit) {
extensions.create("mavenPublicationConfig", MavenPublicationConfigExtension::class.java).apply(fn)
}

9
gradle-plugins/compose/build.gradle.kts

@ -12,12 +12,15 @@ plugins {
gradlePluginConfig {
pluginId = "org.jetbrains.compose"
artifactId = "compose-gradle-plugin"
displayName = "JetBrains Compose Plugin"
description = "JetBrains Compose Gradle plugin for easy configuration"
implementationClass = "org.jetbrains.compose.ComposePlugin"
}
mavenPublicationConfig {
displayName = "JetBrains Compose Gradle Plugin"
description = "JetBrains Compose Gradle plugin for easy configuration"
artifactId = "compose-gradle-plugin"
}
buildConfig {
packageName = "org.jetbrains.compose"
clsName = "ComposeBuildConfig"

Loading…
Cancel
Save