From 58b0a22fb51a1154d865f3358f6c637f81659c83 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov <654232+AlexeyTsvetkov@users.noreply.github.com> Date: Tue, 4 Oct 2022 06:02:28 +0200 Subject: [PATCH] Allow customizing Compose compiler plugin (#2347) By default, the Compose Multiplatform Gradle plugin uses `org.jetbrains.compose.compiler:compiler:` as a compiler plugin . However, a new version of Kotlin might be incompatible with the default version of compiler plugin. Previously, that forced users to update to a new version of Compose Gradle plugin & Compose libraries in order to use a new version of Kotlin. Accordingly, Compose framework developers had to release a new version of all libraries, when a new version of Kotlin is released. Some time ago the Compose team at Google made it possible to update a compiler plugin without updating the Gradle plugin and/or all Compose libraries https://developer.android.com/jetpack/androidx/releases/compose-kotlin This change allows to specify a custom compiler artifact by using the following DSL: ``` compose { kotlinCompilerPlugin.set("::") } ``` --- .../src/main/kotlin/BuildProperties.kt | 9 +- gradle-plugins/compose/build.gradle.kts | 14 ++- .../ComposeCompilerKotlinSupportPlugin.kt | 23 ++-- .../org/jetbrains/compose/ComposeExtension.kt | 11 +- .../ComposeCompilerArtifactProvider.kt | 66 +++++++++++ .../compose/test/TestKotlinVersion.kt | 11 -- .../jetbrains/compose/test/TestProperties.kt | 20 ---- .../integration}/DesktopApplicationTest.kt | 24 +++- .../tests/integration}/GradlePluginTest.kt | 14 +-- .../ComposeCompilerArtifactProviderTest.kt | 107 ++++++++++++++++++ .../{ => test/tests/unit}/FileHashTest.kt | 9 +- .../test/{ => utils}/GradlePluginTestBase.kt | 10 +- .../{ => utils}/GradleTestNameGenerator.kt | 2 +- .../compose/test/utils/TestKotlinVersion.kt | 12 ++ .../compose/test/{ => utils}/TestProject.kt | 14 ++- .../compose/test/{ => utils}/TestProjects.kt | 5 +- .../compose/test/utils/TestProperties.kt | 29 +++++ .../compose/test/{ => utils}/assertUtils.kt | 6 +- .../compose/test/{ => utils}/fileUtils.kt | 2 +- .../compose/test/{ => utils}/processUtils.kt | 2 +- .../test/resources/junit-platform.properties | 2 +- .../androidx-compiler/build.gradle | 31 +++++ .../androidx-compiler/main-image.expected.png | Bin 0 -> 140 bytes .../androidx-compiler/settings.gradle | 11 ++ .../androidx-compiler/src/main/kotlin/Main.kt | 76 +++++++++++++ .../application/defaultArgs/settings.gradle | 2 +- .../defaultArgsOverride/settings.gradle | 2 +- .../application/javaLogger/settings.gradle | 2 +- .../application/jvm/settings.gradle | 2 +- .../application/jvmKotlinDsl/settings.gradle | 2 +- .../application/macOptions/settings.gradle | 2 +- .../application/macSign/settings.gradle | 2 +- .../moduleClashCli/settings.gradle | 2 +- .../application/mpp/settings.gradle | 2 +- .../optionsWithSpaces/settings.gradle | 2 +- .../application/proguard/settings.gradle | 2 +- .../application/resources/settings.gradle | 2 +- .../application/unpackSkiko/settings.gradle | 2 +- .../test-projects/misc/jsMpp/settings.gradle | 2 +- .../misc/jvmPreview/settings.gradle | 2 +- gradle-plugins/gradle.properties | 21 +--- 41 files changed, 451 insertions(+), 110 deletions(-) create mode 100644 gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/ComposeCompilerArtifactProvider.kt delete mode 100644 gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt delete mode 100644 gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProperties.kt rename gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/{gradle => test/tests/integration}/DesktopApplicationTest.kt (94%) rename gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/{gradle => test/tests/integration}/GradlePluginTest.kt (93%) create mode 100644 gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/ComposeCompilerArtifactProviderTest.kt rename gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/{ => test/tests/unit}/FileHashTest.kt (92%) rename gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/{ => utils}/GradlePluginTestBase.kt (58%) rename gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/{ => utils}/GradleTestNameGenerator.kt (93%) create mode 100644 gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersion.kt rename gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/{ => utils}/TestProject.kt (77%) rename gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/{ => utils}/TestProjects.kt (84%) create mode 100644 gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt rename gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/{ => utils}/assertUtils.kt (91%) rename gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/{ => utils}/fileUtils.kt (94%) rename gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/{ => utils}/processUtils.kt (97%) create mode 100644 gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/build.gradle create mode 100644 gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/main-image.expected.png create mode 100644 gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/settings.gradle create mode 100644 gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/src/main/kotlin/Main.kt diff --git a/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt b/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt index 2a48428cb5..07e5a32cdc 100644 --- a/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt +++ b/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt @@ -15,7 +15,14 @@ object BuildProperties { fun composeVersion(project: Project): String = System.getenv("COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION") ?: project.findProperty("compose.version") as String - fun composeCompilerVersion(project: Project): String = project.findProperty("compose.compiler.version") as String + fun composeCompilerVersion(project: Project): String = + project.findProperty("compose.compiler.version") as String + fun composeCompilerCompatibleKotlinVersion(project: Project): String = + project.findProperty("compose.compiler.compatible.kotlin.version") as String + fun testsAndroidxCompilerVersion(project: Project): String = + project.findProperty("compose.tests.androidx.compiler.version") as String + fun testsAndroidxCompilerCompatibleVersion(project: Project): String = + project.findProperty("compose.tests.androidx.compatible.kotlin.version") as String fun deployVersion(project: Project): String = System.getenv("COMPOSE_GRADLE_PLUGIN_VERSION") ?: project.findProperty("deploy.version") as String diff --git a/gradle-plugins/compose/build.gradle.kts b/gradle-plugins/compose/build.gradle.kts index e48c85cda8..4a2914768a 100644 --- a/gradle-plugins/compose/build.gradle.kts +++ b/gradle-plugins/compose/build.gradle.kts @@ -66,6 +66,7 @@ dependencies { testImplementation(gradleTestKit()) testImplementation(platform("org.junit:junit-bom:5.7.0")) testImplementation("org.junit.jupiter:junit-jupiter") + testImplementation(kotlin("gradle-plugin-api")) // include relocated download task to avoid potential runtime conflicts embedded("de.undercouch:gradle-download-task:4.1.1") @@ -105,7 +106,7 @@ val javaHomeForTests: String? = when { } val isWindows = getCurrentOperatingSystem().isWindows -val gradleTestsPattern = "org.jetbrains.compose.gradle.*" +val gradleTestsPattern = "org.jetbrains.compose.test.tests.integration.*" // check we don't accidentally including unexpected classes (e.g. from embedded dependencies) val checkJar by tasks.registering { @@ -161,7 +162,7 @@ fun testGradleVersion(gradleVersion: String) { tasks.test.get().let { defaultTest -> classpath = defaultTest.classpath } - systemProperty("gradle.version.for.tests", gradleVersion) + systemProperty("compose.tests.gradle.version", gradleVersion) filter { includeTestsMatching(gradleTestsPattern) } @@ -177,8 +178,13 @@ tasks.withType().configureEach { configureJavaForComposeTest() dependsOn(":publishToMavenLocal") - systemProperty("compose.plugin.version", BuildProperties.deployVersion(project)) - systemProperty("kotlin.version", project.property("kotlin.version").toString()) + + systemProperty("compose.tests.compose.gradle.plugin.version", BuildProperties.deployVersion(project)) + for ((k, v) in project.properties) { + if (k.startsWith("compose.")) { + systemProperty(k, v.toString()) + } + } } task("printAllAndroidxReplacements") { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt index f5bfb8d5fc..e33c1628f3 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt @@ -5,25 +5,32 @@ package org.jetbrains.compose +import org.gradle.api.Project import org.gradle.api.provider.Provider +import org.jetbrains.compose.internal.ComposeCompilerArtifactProvider import org.jetbrains.compose.internal.webExt import org.jetbrains.kotlin.gradle.plugin.* import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin { + private var composeCompilerArtifactProvider = ComposeCompilerArtifactProvider { null } + + override fun apply(target: Project) { + super.apply(target) + target.plugins.withType(ComposePlugin::class.java) { + val composeExt = target.extensions.getByType(ComposeExtension::class.java) + composeCompilerArtifactProvider = ComposeCompilerArtifactProvider { composeExt.kotlinCompilerPlugin.orNull } + } + } + override fun getCompilerPluginId(): String = "androidx.compose.compiler.plugins.kotlin" - override fun getPluginArtifactForNative(): SubpluginArtifact = - composeCompilerArtifact("compiler-hosted") - override fun getPluginArtifact(): SubpluginArtifact = - composeCompilerArtifact("compiler") + composeCompilerArtifactProvider.compilerArtifact - private fun composeCompilerArtifact(artifactId: String) = - SubpluginArtifact( - groupId = "org.jetbrains.compose.compiler", artifactId = artifactId, version = ComposeBuildConfig.composeCompilerVersion - ) + override fun getPluginArtifactForNative(): SubpluginArtifact = + composeCompilerArtifactProvider.compilerHostedArtifact override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean = when (kotlinCompilation.target.platformType) { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeExtension.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeExtension.kt index b17ff5e5a2..8b3644e6c6 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeExtension.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeExtension.kt @@ -5,6 +5,15 @@ package org.jetbrains.compose +import org.gradle.api.model.ObjectFactory import org.gradle.api.plugins.ExtensionAware +import org.gradle.api.provider.Property +import org.jetbrains.compose.desktop.application.internal.nullableProperty +import javax.inject.Inject + +abstract class ComposeExtension @Inject constructor( + objects: ObjectFactory +) : ExtensionAware { + val kotlinCompilerPlugin: Property = objects.nullableProperty() +} -abstract class ComposeExtension : ExtensionAware \ No newline at end of file diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/ComposeCompilerArtifactProvider.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/ComposeCompilerArtifactProvider.kt new file mode 100644 index 0000000000..4e3ea64f49 --- /dev/null +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/ComposeCompilerArtifactProvider.kt @@ -0,0 +1,66 @@ +/* + * Copyright 2020-2022 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. + */ + +package org.jetbrains.compose.internal + +import org.jetbrains.compose.ComposeBuildConfig +import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact + +internal class ComposeCompilerArtifactProvider(private val customPluginString: () -> String?) { + val compilerArtifact: SubpluginArtifact + get() { + val customPlugin = customPluginString() + val customCoordinates = customPlugin?.split(":") + return when (customCoordinates?.size) { + null -> DefaultCompiler.pluginArtifact + 1 -> { + val customVersion = customCoordinates[0] + check(customVersion.isNotBlank()) { "'compose.kotlinCompilerPlugin' cannot be blank!" } + DefaultCompiler.pluginArtifact.copy(version = customVersion) + } + 3 -> DefaultCompiler.pluginArtifact.copy( + groupId = customCoordinates[0], + artifactId = customCoordinates[1], + version = customCoordinates[2] + ) + else -> error(""" + Illegal format of 'compose.kotlinCompilerPlugin' property. + Expected format: either '' or '::' + Actual value: '$customPlugin' + """.trimIndent()) + } + } + + val compilerHostedArtifact: SubpluginArtifact + get() = compilerArtifact.run { + val newArtifactId = + if (groupId == DefaultCompiler.GROUP_ID && artifactId == DefaultCompiler.ARTIFACT_ID) { + DefaultCompiler.HOSTED_ARTIFACT_ID + } else artifactId + + copy(artifactId = newArtifactId) + } + + internal object DefaultCompiler { + const val GROUP_ID = "org.jetbrains.compose.compiler" + const val ARTIFACT_ID = "compiler" + const val HOSTED_ARTIFACT_ID = "compiler-hosted" + const val VERSION = ComposeBuildConfig.composeCompilerVersion + + val pluginArtifact: SubpluginArtifact + get() = SubpluginArtifact(groupId = GROUP_ID, artifactId = ARTIFACT_ID, version = VERSION) + } +} + +internal fun SubpluginArtifact.copy( + groupId: String? = null, + artifactId: String? = null, + version: String? = null +): SubpluginArtifact = + SubpluginArtifact( + groupId = groupId ?: this.groupId, + artifactId = artifactId ?: this.artifactId, + version = version ?: this.version + ) \ No newline at end of file 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 deleted file mode 100644 index 165e0f7508..0000000000 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt +++ /dev/null @@ -1,11 +0,0 @@ -/* - * 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. - */ - -package org.jetbrains.compose.test - -@Suppress("EnumEntryName") -enum class TestKotlinVersion(val versionString: String) { - Default(TestProperties.defaultKotlinVersion) -} \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProperties.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProperties.kt deleted file mode 100644 index a7f5553f9e..0000000000 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProperties.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ - -package org.jetbrains.compose.test - -object TestProperties { - val defaultKotlinVersion: String - get() = notNullSystemProperty("kotlin.version") - - val composeVersion: String - get() = notNullSystemProperty("compose.plugin.version") - - val gradleVersionForTests: String? - get() = System.getProperty("gradle.version.for.tests") - - private fun notNullSystemProperty(property: String): String = - System.getProperty(property) ?: error("The '$property' system property is not set") -} diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/DesktopApplicationTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt similarity index 94% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/DesktopApplicationTest.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt index f6c2bd5339..ef992a6fc0 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/DesktopApplicationTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt @@ -1,21 +1,22 @@ /* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Copyright 2020-2022 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. */ -package org.jetbrains.compose.gradle +package org.jetbrains.compose.test.tests.integration import org.gradle.internal.impldep.org.testng.Assert import org.gradle.testkit.runner.TaskOutcome import org.jetbrains.compose.desktop.application.internal.* -import org.jetbrains.compose.test.* -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assumptions -import org.junit.jupiter.api.Test +import org.jetbrains.compose.test.utils.* + import java.io.File import java.util.* import java.util.jar.JarFile import kotlin.collections.HashSet +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assumptions +import org.junit.jupiter.api.Test class DesktopApplicationTest : GradlePluginTestBase() { @Test @@ -56,6 +57,17 @@ class DesktopApplicationTest : GradlePluginTestBase() { } } + @Test + fun testAndroidxCompiler() = with(testProject(TestProjects.androidxCompiler, defaultAndroidxCompilerEnvironment)) { + gradle(":runDistributable").build().checks { check -> + val actualMainImage = file("main-image.actual.png") + val expectedMainImage = file("main-image.expected.png") + assert(actualMainImage.readBytes().contentEquals(expectedMainImage.readBytes())) { + "The actual image '$actualMainImage' does not match the expected image '$expectedMainImage'" + } + } + } + @Test fun kotlinDsl(): Unit = with(testProject(TestProjects.jvmKotlinDsl)) { gradle(":package", "--dry-run").build() 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/test/tests/integration/GradlePluginTest.kt similarity index 93% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/GradlePluginTest.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt index a735da46c2..0656251938 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/GradlePluginTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt @@ -1,25 +1,23 @@ /* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Copyright 2020-2022 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. */ -package org.jetbrains.compose.gradle +package org.jetbrains.compose.test.tests.integration -import org.gradle.testkit.runner.TaskOutcome import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.PreviewLogger import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.RemoteConnection import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.receiveConfigFromGradle -import org.jetbrains.compose.test.GradlePluginTestBase -import org.jetbrains.compose.test.TestKotlinVersion -import org.jetbrains.compose.test.TestProjects -import org.jetbrains.compose.test.checks -import org.junit.jupiter.api.Test +import org.jetbrains.compose.test.utils.* + import java.net.ServerSocket import java.net.Socket import java.net.SocketTimeoutException import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicInteger import kotlin.concurrent.thread +import org.gradle.testkit.runner.TaskOutcome +import org.junit.jupiter.api.Test class GradlePluginTest : GradlePluginTestBase() { @Test diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/ComposeCompilerArtifactProviderTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/ComposeCompilerArtifactProviderTest.kt new file mode 100644 index 0000000000..9c848d2db5 --- /dev/null +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/ComposeCompilerArtifactProviderTest.kt @@ -0,0 +1,107 @@ +/* + * Copyright 2020-2022 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. + */ + +package org.jetbrains.compose.test.tests.unit + +import org.jetbrains.compose.internal.ComposeCompilerArtifactProvider +import org.jetbrains.compose.internal.copy +import org.jetbrains.compose.test.utils.TestProperties +import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact +import org.junit.jupiter.api.Test + +import org.junit.jupiter.api.Assertions.* + +internal class ComposeCompilerArtifactProviderTest { + @Test + fun defaultCompilerArtifact() { + assertArtifactEquals( + Expected.jbCompiler, + Actual.compiler(null) + ) + } + + @Test + fun defaultCompilerHostedArtifact() { + assertArtifactEquals( + Expected.jbCompilerHosted, + Actual.compilerHosted(null) + ) + } + + @Test + fun customVersion() { + assertArtifactEquals( + Expected.jbCompiler.copy(version = "10.20.30"), + Actual.compiler("10.20.30") + ) + } + + @Test + fun customCompiler() { + assertArtifactEquals( + Expected.googleCompiler.copy(version = "1.3.1"), + Actual.compiler("androidx.compose.compiler:compiler:1.3.1") + ) + } + + @Test + fun customCompilerHosted() { + // check that we don't replace artifactId for non-jb compiler + assertArtifactEquals( + Expected.googleCompiler.copy(version = "1.3.1"), + Actual.compilerHosted("androidx.compose.compiler:compiler:1.3.1") + ) + } + + @Test + fun illegalCompiler() { + testIllegalCompiler("androidx.compose.compiler:compiler") + testIllegalCompiler("a:b:c:d") + testIllegalCompiler("") + } + + private fun testIllegalCompiler(pluginString: String?) { + try { + Actual.compiler(pluginString) + } catch (e: Exception) { + return + } + + error("Expected error, but illegal value was accepted: '$pluginString'") + } + + object Actual { + fun compiler(pluginString: String?) = + ComposeCompilerArtifactProvider { pluginString }.compilerArtifact + + fun compilerHosted(pluginString: String?) = + ComposeCompilerArtifactProvider { pluginString }.compilerHostedArtifact + } + + object Expected { + val jbCompiler: SubpluginArtifact + get() = SubpluginArtifact( + groupId = "org.jetbrains.compose.compiler", + artifactId = "compiler", + version = TestProperties.composeCompilerVersion + ) + + val jbCompilerHosted: SubpluginArtifact + get() = jbCompiler.copy(artifactId = "compiler-hosted") + + val googleCompiler: SubpluginArtifact + get() = jbCompiler.copy(groupId = "androidx.compose.compiler") + } + + private fun assertArtifactEquals( + expected: SubpluginArtifact, + actual: SubpluginArtifact + ) { + assertEquals(expected.asString(), actual.asString()) + } + + private fun SubpluginArtifact.asString(): String = + "SubpluginArtifact(groupId = '$groupId', artifactId = '$artifactId', version = '$version')" +} \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/FileHashTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/FileHashTest.kt similarity index 92% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/FileHashTest.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/FileHashTest.kt index a92e26a8e9..a49a7aa6ef 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/FileHashTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/FileHashTest.kt @@ -1,14 +1,15 @@ /* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Copyright 2020-2022 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. */ -package org.jetbrains.compose +package org.jetbrains.compose.test.tests.unit -import org.gradle.internal.impldep.org.testng.Assert import org.jetbrains.compose.desktop.application.internal.OS import org.jetbrains.compose.desktop.application.internal.currentOS import org.jetbrains.compose.desktop.application.internal.files.contentHash + +import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir import java.io.File @@ -40,7 +41,7 @@ class FileHashTest { val initHash = initJar.contentHash() val modifiedHash = modifiedJar.contentHash() - Assert.assertNotEquals(modifiedHash, initHash) + assertNotEquals(modifiedHash, initHash) } private fun createJar(outputFileName: String, vararg files: File): File { diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradlePluginTestBase.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradlePluginTestBase.kt similarity index 58% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradlePluginTestBase.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradlePluginTestBase.kt index d2a8d84dcf..17bdfaa0fc 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradlePluginTestBase.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradlePluginTestBase.kt @@ -1,9 +1,9 @@ /* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Copyright 2020-2022 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. */ -package org.jetbrains.compose.test +package org.jetbrains.compose.test.utils import org.junit.jupiter.api.io.TempDir import java.io.File @@ -15,6 +15,12 @@ abstract class GradlePluginTestBase { val defaultTestEnvironment: TestEnvironment get() = TestEnvironment(workingDir = testWorkDir) + val defaultAndroidxCompilerEnvironment: TestEnvironment + get() = defaultTestEnvironment.copy( + kotlinVersion = TestKotlinVersion.AndroidxCompatible, + composeCompilerArtifact = "androidx.compose.compiler:compiler:${TestProperties.androidxCompilerVersion}" + ) + fun testProject( name: String, testEnvironment: TestEnvironment = defaultTestEnvironment diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradleTestNameGenerator.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradleTestNameGenerator.kt similarity index 93% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradleTestNameGenerator.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradleTestNameGenerator.kt index 817aa82ed8..b421edd922 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradleTestNameGenerator.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradleTestNameGenerator.kt @@ -3,7 +3,7 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. */ -package org.jetbrains.compose.test +package org.jetbrains.compose.test.utils import org.junit.jupiter.api.DisplayNameGenerator diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersion.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersion.kt new file mode 100644 index 0000000000..f2b24d983f --- /dev/null +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersion.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2020-2022 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. + */ + +package org.jetbrains.compose.test.utils + +@Suppress("EnumEntryName") +enum class TestKotlinVersion(val versionString: String) { + Default(TestProperties.composeCompilerCompatibleKotlinVersion), + AndroidxCompatible(TestProperties.androidxCompilerCompatibleKotlinVersion) +} \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProject.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt similarity index 77% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProject.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt index f76292d0c2..dc775b35ce 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProject.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt @@ -1,9 +1,9 @@ /* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Copyright 2020-2022 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. */ -package org.jetbrains.compose.test +package org.jetbrains.compose.test.utils import org.gradle.testkit.runner.GradleRunner import org.jetbrains.compose.desktop.application.internal.ComposeProperties @@ -12,7 +12,8 @@ import java.io.File data class TestEnvironment( val workingDir: File, val kotlinVersion: TestKotlinVersion = TestKotlinVersion.Default, - val composeVersion: String = TestProperties.composeVersion + val composeGradlePluginVersion: String = TestProperties.composeGradlePluginVersion, + val composeCompilerArtifact: String? = null ) class TestProject( @@ -38,9 +39,12 @@ class TestProject( if (orig.name.endsWith(".gradle") || orig.name.endsWith(".gradle.kts")) { val origContent = orig.readText() - val newContent = origContent - .replace("COMPOSE_VERSION_PLACEHOLDER", testEnvironment.composeVersion) + var newContent = origContent + .replace("COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER", testEnvironment.composeGradlePluginVersion) .replace("KOTLIN_VERSION_PLACEHOLDER", testEnvironment.kotlinVersion.versionString) + if (testEnvironment.composeCompilerArtifact != null) { + newContent = newContent.replace("COMPOSE_COMPILER_ARTIFACT_PLACEHOLDER", testEnvironment.composeCompilerArtifact) + } target.writeText(newContent) } else { orig.copyTo(target) diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProjects.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt similarity index 84% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProjects.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt index bc9093ca29..1a6863e839 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProjects.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt @@ -1,14 +1,15 @@ /* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Copyright 2020-2022 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. */ -package org.jetbrains.compose.test +package org.jetbrains.compose.test.utils object TestProjects { const val jvm = "application/jvm" const val mpp = "application/mpp" const val proguard = "application/proguard" + const val androidxCompiler = "application/androidx-compiler" const val jvmKotlinDsl = "application/jvmKotlinDsl" const val moduleClashCli = "application/moduleClashCli" const val javaLogger = "application/javaLogger" diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt new file mode 100644 index 0000000000..84814a6af7 --- /dev/null +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2020-2022 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. + */ + +package org.jetbrains.compose.test.utils + +object TestProperties { + val composeCompilerVersion: String + get() = notNullSystemProperty("compose.compiler.version") + + val composeCompilerCompatibleKotlinVersion: String + get() = notNullSystemProperty("compose.compiler.compatible.kotlin.version") + + val androidxCompilerVersion: String + get() = notNullSystemProperty("compose.tests.androidx.compiler.version") + + val androidxCompilerCompatibleKotlinVersion: String + get() = notNullSystemProperty("compose.tests.androidx.compiler.compatible.kotlin.version") + + val composeGradlePluginVersion: String + get() = notNullSystemProperty("compose.tests.compose.gradle.plugin.version") + + val gradleVersionForTests: String? + get() = System.getProperty("compose.tests.gradle.version") + + private fun notNullSystemProperty(property: String): String = + System.getProperty(property) ?: error("The '$property' system property is not set") +} diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/assertUtils.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/assertUtils.kt similarity index 91% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/assertUtils.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/assertUtils.kt index cc500f0376..45535445df 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/assertUtils.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/assertUtils.kt @@ -1,16 +1,14 @@ /* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Copyright 2020-2022 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. */ -package org.jetbrains.compose.test +package org.jetbrains.compose.test.utils -import org.gradle.internal.impldep.junit.framework.Assert import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.TaskOutcome import org.junit.jupiter.api.Assertions import java.io.File -import kotlin.math.exp internal fun Collection.checkContains(vararg elements: T) { val expectedElements = elements.toMutableSet() diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/fileUtils.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/fileUtils.kt similarity index 94% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/fileUtils.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/fileUtils.kt index ced8ea19a5..dc94686621 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/fileUtils.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/fileUtils.kt @@ -3,7 +3,7 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. */ -package org.jetbrains.compose.test +package org.jetbrains.compose.test.utils import java.io.File diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/processUtils.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/processUtils.kt similarity index 97% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/processUtils.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/processUtils.kt index f310e9a048..4a5e6c9c1f 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/processUtils.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/processUtils.kt @@ -3,7 +3,7 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. */ -package org.jetbrains.compose.test +package org.jetbrains.compose.test.utils import java.io.File diff --git a/gradle-plugins/compose/src/test/resources/junit-platform.properties b/gradle-plugins/compose/src/test/resources/junit-platform.properties index 58522aad15..616bf761e3 100644 --- a/gradle-plugins/compose/src/test/resources/junit-platform.properties +++ b/gradle-plugins/compose/src/test/resources/junit-platform.properties @@ -1 +1 @@ -junit.jupiter.displayname.generator.default=org.jetbrains.compose.test.GradleTestNameGenerator \ No newline at end of file +junit.jupiter.displayname.generator.default=org.jetbrains.compose.test.utils.GradleTestNameGenerator \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/build.gradle b/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/build.gradle new file mode 100644 index 0000000000..1bb4fcdef8 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/build.gradle @@ -0,0 +1,31 @@ +import org.jetbrains.compose.desktop.application.dsl.TargetFormat + +plugins { + id "org.jetbrains.kotlin.jvm" + id "org.jetbrains.compose" +} + +repositories { + google() + jetbrainsCompose() +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib" + implementation compose.desktop.currentOs +} + +compose { + kotlinCompilerPlugin.set("COMPOSE_COMPILER_ARTIFACT_PLACEHOLDER") + + desktop { + application { + mainClass = "Main" + args(project.projectDir.absolutePath) + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + } + args(project.projectDir.absolutePath) + } + } +} diff --git a/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/main-image.expected.png b/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/main-image.expected.png new file mode 100644 index 0000000000000000000000000000000000000000..525220fb6bf3e4ebbd146242c0fb222cc0a89ad5 GIT binary patch literal 140 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u@pObhHwBu4M$1`knim2;us<^ zwe`$FUIqmY=Zk&EUgUh+yTEP2g(cIMRR(b#5}5W~s71NPO0p?qecQJFdeh9kv$pKN ll@Xe|C0usPYQ9^6;;*_1PE?xit literal 0 HcmV?d00001 diff --git a/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/settings.gradle new file mode 100644 index 0000000000..43d540efb8 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/settings.gradle @@ -0,0 +1,11 @@ +pluginManagement { + plugins { + id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' + } + repositories { + mavenLocal() + gradlePluginPortal() + } +} +rootProject.name = "simple" \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/src/main/kotlin/Main.kt b/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/src/main/kotlin/Main.kt new file mode 100644 index 0000000000..e7d73f0092 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/src/main/kotlin/Main.kt @@ -0,0 +1,76 @@ +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.GenericShape +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.renderComposeScene +import org.jetbrains.skia.EncodedImageFormat +import java.io.File +import java.util.* + +object Main { + @JvmStatic + @OptIn(ExperimentalComposeUiApi::class) + fun main(args: Array) { + val workingDir = args.getOrNull(0)?.let { File(it) } + workingDir?.mkdirs() + if (workingDir == null || !workingDir.isDirectory) { + error("Working directory must be passes as the first argument. '$workingDir' is not a directory") + } + + val image = renderComposeScene(height = 10, width = 10) { + mainShape() + } + val encodedImage = image.encodeToData(EncodedImageFormat.PNG) ?: error("Could not encode image as png") + workingDir.resolve("main-image.actual.png").writeBytes(encodedImage.bytes) + + val mainMethods = this.javaClass.declaredMethods + .mapTo(TreeSet()) { it.name } + .joinToString("\n") + workingDir.resolve("main-methods.actual.txt").writeText(mainMethods) + } + + @Composable + fun mainShape() { + triangle(Color.Magenta) + } + + @Composable + fun unused() { + transitivelyUnused() + } + + @Composable + fun transitivelyUnused() { + triangle(Color.Gray) + } + + @Composable + fun keptByKeepRule() { + fillShape(Color.Blue, CircleShape) + } +} + +@Composable +fun triangle(color: Color) { + fillShape(color, GenericShape { size, _ -> + moveTo(size.width / 2f, 0f) + lineTo(size.width, size.height) + lineTo(0f, size.height) + }) +} + +@Composable +fun fillShape(color: Color, shape: Shape){ + Column(modifier = Modifier.fillMaxWidth().wrapContentSize(Alignment.Center)) { + Box( + modifier = Modifier.clip(shape).fillMaxSize().background(color) + ) + } +} \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/test-projects/application/defaultArgs/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/defaultArgs/settings.gradle index 0fcbea6df4..9e2a3a08e0 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/defaultArgs/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/defaultArgs/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/defaultArgsOverride/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/defaultArgsOverride/settings.gradle index 0fcbea6df4..9e2a3a08e0 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/defaultArgsOverride/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/defaultArgsOverride/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/javaLogger/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/javaLogger/settings.gradle index ca60210443..6994155e62 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/javaLogger/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/javaLogger/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/jvm/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/jvm/settings.gradle index 8d7ab43b40..43d540efb8 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/jvm/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/jvm/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/jvmKotlinDsl/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/jvmKotlinDsl/settings.gradle index 8d7ab43b40..43d540efb8 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/jvmKotlinDsl/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/jvmKotlinDsl/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/macOptions/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/macOptions/settings.gradle index 0fcbea6df4..9e2a3a08e0 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/macOptions/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/macOptions/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/macSign/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/macSign/settings.gradle index 0fcbea6df4..9e2a3a08e0 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/macSign/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/macSign/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/moduleClashCli/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/moduleClashCli/settings.gradle index e5b770dca2..0a6293e7be 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/moduleClashCli/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/moduleClashCli/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle index f18e8f72ca..633aadd815 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/settings.gradle index 0fcbea6df4..9e2a3a08e0 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/proguard/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/proguard/settings.gradle index 8d7ab43b40..43d540efb8 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/proguard/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/proguard/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/resources/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/resources/settings.gradle index 8d7ab43b40..43d540efb8 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/resources/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/resources/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/application/unpackSkiko/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/unpackSkiko/settings.gradle index 8d7ab43b40..43d540efb8 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/unpackSkiko/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/unpackSkiko/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/misc/jsMpp/settings.gradle b/gradle-plugins/compose/src/test/test-projects/misc/jsMpp/settings.gradle index 3250aca93b..aace426b6a 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/jsMpp/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/misc/jsMpp/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/compose/src/test/test-projects/misc/jvmPreview/settings.gradle b/gradle-plugins/compose/src/test/test-projects/misc/jvmPreview/settings.gradle index 2db23b4ddc..f5bad52c88 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/jvmPreview/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/misc/jvmPreview/settings.gradle @@ -2,7 +2,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { mavenLocal() diff --git a/gradle-plugins/gradle.properties b/gradle-plugins/gradle.properties index 4ecce17018..440c18771f 100644 --- a/gradle-plugins/gradle.properties +++ b/gradle-plugins/gradle.properties @@ -1,25 +1,16 @@ org.gradle.parallel=true kotlin.code.style=official -# A version of Compose libraries, -# that will be used by published Gradle plugin, -# unless overridden by COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION env var. -# # __LATEST_COMPOSE_RELEASE_VERSION__ +# Default version of Compose Libraries used by Gradle plugin compose.version=1.2.0-alpha01-dev774 - +# Default version of Compose Compiler used by Gradle plugin compose.compiler.version=1.3.0-alpha01 - -# See the corresponding version here: https://developer.android.com/jetpack/androidx/releases/compose-kotlin -# (note, that for the 'org.jetbrains.compose` build we usualy keep only Major and Minor versions the same) -# This is only used on CI for now. +# Default version of Kotlin compatible with compose.compiler.version compose.compiler.compatible.kotlin.version=1.7.10 - -# A version of Kotlin expected by __LATEST_COMPOSE_RELEASE_VERSION__ -# This Kotlin version should be used in test or for checking plugin's compatibility, -# not for building the Gradle plugin itself! -# __KOTLIN_COMPOSE_VERSION__ -kotlin.version=1.7.10 +# https://developer.android.com/jetpack/androidx/releases/compose-kotlin +compose.tests.androidx.compiler.version=1.3.1 +compose.tests.androidx.compiler.compatible.kotlin.version=1.7.10 # A version of Gradle plugin, that will be published, # unless overridden by COMPOSE_GRADLE_PLUGIN_VERSION env var.