Browse Source

Use Gradle 7.1 for building Gradle and Intellij plugin (#836)

* Replace usage of 'de.fuerstenau.buildconfig'
with a custom replacement, because the plugin
does not support Gradle 7.0+ and
there has not been any commit activity in 5 years
(https://github.com/mfuerstenau/gradle-buildconfig-plugin);
* Update 'com.github.johnrengelman.shadow' to 7.0.0
pull/838/head
Alexey Tsvetkov 4 years ago committed by GitHub
parent
commit
e96826c47c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      gradle-plugins/build.gradle.kts
  2. 51
      gradle-plugins/buildSrc/src/main/kotlin/GenerateBuildConfig.kt
  3. 26
      gradle-plugins/compose/build.gradle.kts
  4. 2
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt
  5. 2
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/GradlePluginTest.kt
  6. 2
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt
  7. 2
      gradle-plugins/gradle/wrapper/gradle-wrapper.properties
  8. 2
      idea-plugin/gradle/wrapper/gradle-wrapper.properties

3
gradle-plugins/build.gradle.kts

@ -3,8 +3,7 @@ import com.gradle.publish.PluginBundleExtension
plugins {
// __KOTLIN_COMPOSE_VERSION__
kotlin("jvm") version "1.5.10" apply false
id("com.gradle.plugin-publish") version "0.10.1" apply false
id("de.fuerstenau.buildconfig") version "1.1.8" apply false
id("com.gradle.plugin-publish") version "0.15.0" apply false
}
subprojects {

51
gradle-plugins/buildSrc/src/main/kotlin/GenerateBuildConfig.kt

@ -0,0 +1,51 @@
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.mapProperty
import org.gradle.kotlin.dsl.property
/*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
open class GenerateBuildConfig : DefaultTask() {
@get:Input
val fieldsToGenerate: MapProperty<String, Any> = project.objects.mapProperty()
@get:Input
val classFqName: Property<String> = project.objects.property()
@get:OutputDirectory
val generatedOutputDir: DirectoryProperty = project.objects.directoryProperty()
@TaskAction
fun execute() {
val dir = generatedOutputDir.get().asFile
dir.deleteRecursively()
dir.mkdirs()
val fqName = classFqName.get()
val parts = fqName.split(".")
val className = parts.last()
val file = dir.resolve("$className.kt")
val content = buildString {
if (parts.size > 1) {
appendLine("package ${parts.dropLast(1).joinToString(".")}")
}
appendLine()
appendLine("/* GENERATED, DO NOT EDIT MANUALLY! */")
appendLine("object $className {")
for ((k, v) in fieldsToGenerate.get().entries.sortedBy { it.key }) {
appendLine("const val $k = ${if (v is String) "\"$v\"" else v.toString()}")
}
appendLine("}")
}
file.writeText(content)
}
}

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

@ -3,11 +3,10 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurr
plugins {
kotlin("jvm")
id("de.fuerstenau.buildconfig")
id("com.gradle.plugin-publish")
id("java-gradle-plugin")
id("maven-publish")
id("com.github.johnrengelman.shadow") version "6.1.0"
id("com.github.johnrengelman.shadow") version "7.0.0"
}
gradlePluginConfig {
@ -21,11 +20,19 @@ mavenPublicationConfig {
artifactId = "compose-gradle-plugin"
}
buildConfig {
packageName = "org.jetbrains.compose"
clsName = "ComposeBuildConfig"
buildConfigField("String", "composeVersion", BuildProperties.composeVersion(project))
buildConfigField("Boolean", "isComposeWithWeb", BuildProperties.isComposeWithWeb(project).toString())
val buildConfigDir
get() = project.layout.buildDirectory.dir("generated/buildconfig")
val buildConfig = tasks.register("buildConfig", GenerateBuildConfig::class.java) {
classFqName.set("org.jetbrains.compose.ComposeBuildConfig")
generatedOutputDir.set(buildConfigDir)
fieldsToGenerate.put("composeVersion", BuildProperties.composeVersion(project))
fieldsToGenerate.put("isComposeWithWeb", BuildProperties.isComposeWithWeb(project))
}
tasks.named("compileKotlin") {
dependsOn(buildConfig)
}
sourceSets.main.configure {
java.srcDir(buildConfigDir)
}
val embedded by configurations.creating
@ -67,7 +74,7 @@ val jar = tasks.named<Jar>("jar") {
// __SUPPORTED_GRADLE_VERSIONS__
testGradleVersion("6.4")
testGradleVersion("6.8.3")
testGradleVersion("7.0-milestone-3")
testGradleVersion("7.1")
val javaHomeForTests: String? = when {
// __COMPOSE_NATIVE_DISTRIBUTIONS_MIN_JAVA_VERSION__
@ -92,7 +99,6 @@ fun testGradleVersion(gradleVersion: String) {
filter {
includeTestsMatching(gradleTestsPattern)
}
dependsOn("validateTaskProperties")
}
tasks.named("check") {
dependsOn(taskProvider)
@ -104,7 +110,7 @@ configureJUnit()
tasks.withType<Test>().configureEach {
configureJavaForComposeTest()
dependsOn("publishToMavenLocal")
dependsOn(":publishToMavenLocal")
systemProperty("compose.plugin.version", BuildProperties.deployVersion(project))
}

2
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt

@ -37,7 +37,7 @@ abstract class AbstractConfigureDesktopPreviewTask : AbstractComposeDesktopTask(
@get:InputFiles
internal val hostClasspath = project.configurations.detachedConfiguration(
project.dependencies.create("org.jetbrains.compose:preview-rpc:${ComposeBuildConfig.VERSION}")
project.dependencies.create("org.jetbrains.compose:preview-rpc:${ComposeBuildConfig.composeVersion}")
)
@TaskAction

2
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/GradlePluginTest.kt

@ -18,7 +18,7 @@ class GradlePluginTest : GradlePluginTestBase() {
with(
testProject(
TestProjects.jsMpp,
testEnvironment = defaultTestEnvironment.copy(kotlinVersion = TestKotlinVersion.V1_5_20_dev_3226)
testEnvironment = defaultTestEnvironment.copy(kotlinVersion = TestKotlinVersion.V1_5_20)
)
) {
gradle(":compileKotlinJs").build().checks { check ->

2
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt

@ -9,5 +9,5 @@ package org.jetbrains.compose.test
enum class TestKotlinVersion(val versionString: String) {
// __KOTLIN_COMPOSE_VERSION__
Default("1.5.10"),
V1_5_20_dev_3226("1.5.20-dev-3226")
V1_5_20("1.5.20")
}

2
gradle-plugins/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
idea-plugin/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Loading…
Cancel
Save