Browse Source

Refactor gradle-plugin build configuration to allow other plugins

So other plugins can be added to separate subprojects
pull/28/head
Alexey Tsvetkov 4 years ago committed by Alexey Tsvetkov
parent
commit
a8e34eddad
  1. 2
      README.md
  2. 7
      gradle-plugin/.idea/vcs.xml
  3. 5
      gradle-plugin/README.md
  4. 88
      gradle-plugin/build.gradle.kts
  5. 0
      gradle-plugins/.gitignore
  6. 5
      gradle-plugins/README.md
  7. 83
      gradle-plugins/build.gradle.kts
  8. 12
      gradle-plugins/buildSrc/build.gradle.kts
  9. 5
      gradle-plugins/buildSrc/settings.gradle.kts
  10. 11
      gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt
  11. 17
      gradle-plugins/buildSrc/src/main/kotlin/GradlePluginConfigExtension.kt
  12. 5
      gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt
  13. 28
      gradle-plugins/compose/build.gradle.kts
  14. 0
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt
  15. 0
      gradle-plugins/compose/src/main/resources/META-INF/gradle-plugins/org.jetbrains.compose.properties
  16. 0
      gradle-plugins/gradle/wrapper/gradle-wrapper.jar
  17. 0
      gradle-plugins/gradle/wrapper/gradle-wrapper.properties
  18. 0
      gradle-plugins/gradlew
  19. 0
      gradle-plugins/gradlew.bat
  20. 4
      gradle-plugins/settings.gradle.kts

2
README.md

@ -12,6 +12,6 @@ at https://android.googlesource.com/platform/frameworks/support.
* `examples` - examples of multiplatform Compose applications for Desktop and Android
* `imageviewer` - Image Viewer application for Android and Desktop
* `issues` - GitHub issue tracker with an adaptive UI and ktor-client
* `gradle-plugin` - plugin for simpler usage of Compose with Gradle build
* `gradle-plugins` - plugins, simplifying usage of Compose with Gradle
* `templates` - new application templates (see `desktop-template/build_and_run_from_cli_example.sh` for using without Gradle)
* `tutorials` - tutorials on using Compose for Desktop

7
gradle-plugin/.idea/vcs.xml

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

5
gradle-plugin/README.md

@ -1,5 +0,0 @@
Jetpack Compose gradle plugin for easy configuration
Environment variables:
COMPOSE_GRADLE_PLUGIN_VERSION - version of plugin
COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION - version of Jetpack Compose which will be used when the plugin is applied

88
gradle-plugin/build.gradle.kts

@ -1,88 +0,0 @@
plugins {
kotlin("jvm") version "1.4.0"
id("com.gradle.plugin-publish") version "0.10.1"
id("de.fuerstenau.buildconfig") version "1.1.8"
id("java-gradle-plugin")
id("maven-publish")
}
private object Info {
const val name = "Jetpack Compose Plugin"
const val website = "https://jetbrains.org/compose"
const val description = "Jetpack Compose gradle plugin for easy configuration"
const val artifactId = "compose-gradle-plugin"
val composeVersion = System.getenv("COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION") ?: "0.1.0-SNAPSHOT"
val version = System.getenv("COMPOSE_GRADLE_PLUGIN_VERSION") ?: composeVersion
}
group = "org.jetbrains.compose"
version = Info.version
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
maven("https://dl.bintray.com/kotlin/kotlin-dev")
jcenter()
mavenLocal()
}
dependencies {
implementation(gradleApi())
implementation(localGroovy())
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin")
testImplementation(gradleTestKit())
}
buildConfig {
packageName = "org.jetbrains.compose"
clsName = "ComposeBuildConfig"
buildConfigField("String", "composeVersion", Info.composeVersion)
}
gradlePlugin {
plugins {
create("compose") {
id = "org.jetbrains.compose"
displayName = Info.name
description = Info.description
implementationClass = "org.jetbrains.compose.ComposePlugin"
version = project.version
}
}
}
pluginBundle {
website = Info.website
description = Info.description
}
publishing {
repositories {
maven {
setUrl(System.getenv("COMPOSE_REPO_URL"))
credentials {
username = System.getenv("COMPOSE_REPO_USERNAME")
password = System.getenv("COMPOSE_REPO_KEY")
}
}
}
publications {
create<MavenPublication>("pluginMaven") {
artifactId = Info.artifactId
pom {
name.set(Info.name)
description.set(Info.description)
url.set(Info.website)
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
}
}
}

0
gradle-plugin/.gitignore → gradle-plugins/.gitignore vendored

5
gradle-plugins/README.md

@ -0,0 +1,5 @@
Jetpack Compose gradle plugin for easy configuration
Environment variables:
* `COMPOSE_GRADLE_PLUGIN_VERSION` - version of plugin
* `COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION` - version of Jetpack Compose used by the plugin

83
gradle-plugins/build.gradle.kts

@ -0,0 +1,83 @@
import com.gradle.publish.PluginBundleExtension
plugins {
kotlin("jvm") version "1.4.0" apply false
id("com.gradle.plugin-publish") version "0.10.1" apply false
id("de.fuerstenau.buildconfig") version "1.1.8" apply false
}
subprojects {
group = BuildProperties.group
version = BuildProperties.version
repositories {
maven("https://dl.bintray.com/kotlin/kotlin-dev")
jcenter()
mavenLocal()
}
plugins.withId("java") {
configureIfExists<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
plugins.withId("maven-publish") {
configureIfExists<PublishingExtension> {
repositories {
maven("ComposeRepo") {
setUrl(System.getenv("COMPOSE_REPO_URL"))
credentials {
username = System.getenv("COMPOSE_REPO_USERNAME")
password = System.getenv("COMPOSE_REPO_KEY")
}
}
}
}
}
afterEvaluate {
gradlePluginConfig?.let { configureGradlePlugin(it) }
}
}
fun Project.configureGradlePlugin(config: GradlePluginConfigExtension) {
// maven publication for plugin
configureIfExists<PublishingExtension> {
publications.create<MavenPublication>("gradlePlugin") {
artifactId = config.artifactId
pom {
name.set(config.displayName)
description.set(config.description)
url.set(BuildProperties.website)
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
}
}
// 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
}
// 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
version = project.version
}
}
}
}

12
gradle-plugins/buildSrc/build.gradle.kts

@ -0,0 +1,12 @@
plugins {
`kotlin-dsl`
}
repositories {
gradlePluginPortal()
}
dependencies {
compileOnly(gradleApi())
implementation(kotlin("stdlib"))
}

5
gradle-plugins/buildSrc/settings.gradle.kts

@ -0,0 +1,5 @@
pluginManagement {
repositories {
gradlePluginPortal()
}
}

11
gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt

@ -0,0 +1,11 @@
// "Global" properties
object BuildProperties {
const val name = "Jetpack Compose Plugin"
const val group = "org.jetbrains.compose"
const val website = "https://jetbrains.org/compose"
const val vcs = "https://github.com/JetBrains/compose-jb"
val composeVersion: String
get() = System.getenv("COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION") ?: "0.1.0-SNAPSHOT"
val version: String
get() = System.getenv("COMPOSE_GRADLE_PLUGIN_VERSION") ?: composeVersion
}

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

@ -0,0 +1,17 @@
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?
get() = extensions.findByType(GradlePluginConfigExtension::class.java)
fun Project.gradlePluginConfig(fn: GradlePluginConfigExtension.() -> Unit) {
extensions.create("gradlePluginConfig", GradlePluginConfigExtension::class.java).apply(fn)
}

5
gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt

@ -0,0 +1,5 @@
import org.gradle.api.Project
inline fun <reified T> Project.configureIfExists(fn: T.() -> Unit) {
extensions.findByType(T::class.java)?.fn()
}

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

@ -0,0 +1,28 @@
plugins {
kotlin("jvm")
id("de.fuerstenau.buildconfig")
id("com.gradle.plugin-publish")
id("java-gradle-plugin")
id("maven-publish")
}
gradlePluginConfig {
pluginId = "org.jetbrains.compose"
artifactId = "compose-gradle-plugin"
displayName = "Jetpack Compose Plugin"
description = "Jetpack Compose gradle plugin for easy configuration"
implementationClass = "org.jetbrains.compose.ComposePlugin"
}
buildConfig {
packageName = "org.jetbrains.compose"
clsName = "ComposeBuildConfig"
buildConfigField("String", "composeVersion", BuildProperties.composeVersion)
}
dependencies {
compileOnly(gradleApi())
compileOnly(localGroovy())
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin")
testImplementation(gradleTestKit())
}

0
gradle-plugin/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt → gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt

0
gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.jetbrains.compose.properties → gradle-plugins/compose/src/main/resources/META-INF/gradle-plugins/org.jetbrains.compose.properties

0
gradle-plugin/gradle/wrapper/gradle-wrapper.jar → gradle-plugins/gradle/wrapper/gradle-wrapper.jar vendored

0
gradle-plugin/gradle/wrapper/gradle-wrapper.properties → gradle-plugins/gradle/wrapper/gradle-wrapper.properties vendored

0
gradle-plugin/gradlew → gradle-plugins/gradlew vendored

0
gradle-plugin/gradlew.bat → gradle-plugins/gradlew.bat vendored

4
gradle-plugin/settings.gradle.kts → gradle-plugins/settings.gradle.kts

@ -3,4 +3,6 @@ pluginManagement {
gradlePluginPortal()
maven("https://dl.bintray.com/kotlin/kotlin-dev")
}
}
}
include(":compose")
Loading…
Cancel
Save