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