From e96826c47c7c7b63cd85d029ac34049869abc565 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov <654232+AlexeyTsvetkov@users.noreply.github.com> Date: Wed, 30 Jun 2021 17:52:45 +0300 Subject: [PATCH 1/2] 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 --- gradle-plugins/build.gradle.kts | 3 +- .../src/main/kotlin/GenerateBuildConfig.kt | 51 +++++++++++++++++++ gradle-plugins/compose/build.gradle.kts | 26 ++++++---- .../AbstractConfigureDesktopPreviewTask.kt | 2 +- .../compose/gradle/GradlePluginTest.kt | 2 +- .../compose/test/TestKotlinVersion.kt | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 8 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 gradle-plugins/buildSrc/src/main/kotlin/GenerateBuildConfig.kt diff --git a/gradle-plugins/build.gradle.kts b/gradle-plugins/build.gradle.kts index 1c9c5500b2..ea79ed7130 100644 --- a/gradle-plugins/build.gradle.kts +++ b/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 { diff --git a/gradle-plugins/buildSrc/src/main/kotlin/GenerateBuildConfig.kt b/gradle-plugins/buildSrc/src/main/kotlin/GenerateBuildConfig.kt new file mode 100644 index 0000000000..d833edd89e --- /dev/null +++ b/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 = project.objects.mapProperty() + + @get:Input + val classFqName: Property = 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) + } +} \ No newline at end of file diff --git a/gradle-plugins/compose/build.gradle.kts b/gradle-plugins/compose/build.gradle.kts index fbc0223ad2..951e4be8fb 100644 --- a/gradle-plugins/compose/build.gradle.kts +++ b/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") { // __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().configureEach { configureJavaForComposeTest() - dependsOn("publishToMavenLocal") + dependsOn(":publishToMavenLocal") systemProperty("compose.plugin.version", BuildProperties.deployVersion(project)) } diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt index 9348bcfa73..4333b447da 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt +++ b/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 diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/GradlePluginTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/GradlePluginTest.kt index b54d2521ac..42e0e75cca 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/GradlePluginTest.kt +++ b/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 -> diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt index 38bbc16fb3..8694aa6738 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt +++ b/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") } \ No newline at end of file diff --git a/gradle-plugins/gradle/wrapper/gradle-wrapper.properties b/gradle-plugins/gradle/wrapper/gradle-wrapper.properties index 25d3265315..69a9715077 100644 --- a/gradle-plugins/gradle/wrapper/gradle-wrapper.properties +++ b/gradle-plugins/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/idea-plugin/gradle/wrapper/gradle-wrapper.properties b/idea-plugin/gradle/wrapper/gradle-wrapper.properties index 442d9132ea..69a9715077 100644 --- a/idea-plugin/gradle/wrapper/gradle-wrapper.properties +++ b/idea-plugin/gradle/wrapper/gradle-wrapper.properties @@ -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 From 8131b6665dae5bdc947dfda0b6887033f80d42df Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Wed, 30 Jun 2021 17:06:06 +0200 Subject: [PATCH 2/2] Remove accidentaly wrongly merge code from a debug branch --- .../web/tests/integration/common/BaseIntegrationTests.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt b/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt index 50847d4dfe..686dfb48f2 100644 --- a/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt +++ b/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt @@ -10,12 +10,10 @@ import org.openqa.selenium.chrome.ChromeDriver import org.openqa.selenium.chrome.ChromeOptions import org.openqa.selenium.firefox.FirefoxDriver import org.openqa.selenium.firefox.FirefoxOptions -import org.openqa.selenium.remote.RemoteWebDriver import org.openqa.selenium.safari.SafariDriver import org.openqa.selenium.support.ui.ExpectedConditions import org.openqa.selenium.support.ui.WebDriverWait - private val PATH = "http://localhost:${ServerLauncher.port}" fun WebDriver.openTestPage(test: String) { @@ -41,8 +39,6 @@ internal object Drivers { val Firefox by lazy { object : FirefoxDriver( FirefoxOptions().apply { -// System.setProperty("webdriver.gecko.driver","G:\\Selenium\\Firefox driver\\geckodriver.exe"); - System.setProperty("webdriver.gecko.driver","C:\\Users\\Shagen\\.gradle\\selenium\\gecko\\geckodriver.exe"); setHeadless(true) } ) {