diff --git a/README.md b/README.md index 028d82af36..1cebe2567f 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,9 @@ # Compose Multiplatform, by JetBrains ![](artwork/readme/apps.png) -Compose Kotlin UI framework port for desktop platforms (macOS, Linux, Windows) and Web, components outside of the core Compose repository -at https://android.googlesource.com/platform/frameworks/support. +Compose Kotlin UI framework port for desktop platforms (macOS, Linux, Windows) and Web, components outside of the core [Compose repository](https://android.googlesource.com/platform/frameworks/support). -Preview functionality (check your application UI without building/running it) for desktop platforms is available via IDEA plugin (https://plugins.jetbrains.com/plugin/16541-compose-multiplatform-ide-support). +Preview functionality (check your application UI without building/running it) for desktop platforms is available via [IDEA plugin](https://plugins.jetbrains.com/plugin/16541-compose-multiplatform-ide-support). ## Tutorials ### Compose for Desktop @@ -70,6 +69,9 @@ Note that when you use Compose Multiplatform, you setup your project differently * [LWJGL integration](experimental/lwjgl-integration) - An example showing how to integrate Compose with [LWJGL](https://www.lwjgl.org) * [CLI example](experimental/build_from_cli) - An example showing how to build Compose without Gradle -## Getting latest version of Compose Multiplatform ## +## Versions ## -See https://github.com/JetBrains/compose-jb/releases/latest for the latest stable release or https://github.com/JetBrains/compose-jb/releases for all stable and dev releases. +* [The latest stable release](https://github.com/JetBrains/compose-jb/releases/latest) +* [The latest dev release](https://github.com/JetBrains/compose-jb/releases) +* [Compatability and versioning overview](VERSIONING.md) +* [Changelog](CHANGELOG.md) diff --git a/FEATURES.md b/VERSIONING.md similarity index 62% rename from FEATURES.md rename to VERSIONING.md index 0d7a784719..5a7d836536 100644 --- a/FEATURES.md +++ b/VERSIONING.md @@ -21,12 +21,13 @@ Knowing issues on older versions: ### Kotlin compatibility -Compose version | Kotlin version ---- | --- -1.0.0+ | 1.5.31 -1.0.1-rc2+ | 1.6.10 - - -### Gradle plugin compatibility - -* 1.0.0 works with Gradle 6.7 or later (7.2 is the latest tested version). +A new version of Kotlin may be not supported immediately after its release. But after some time we will release a version of Compose Multiplatform +that supports it. +Starting from 1.2.0, Compose Multiplatform supports multiple versions of Kotlin. + +Kotlin version | Minimal Compose version | Notes +--- | --- | --- +1.5.31 | 1.0.0 +1.6.20 | 1.1.1 +1.7.10 | 1.2.0 +1.7.20 | 1.2.0 | JS is not supported (will be fixed in the next versions) diff --git a/examples/validateExamples.sh b/examples/validateExamples.sh index c970e81e66..83b61d17e9 100755 --- a/examples/validateExamples.sh +++ b/examples/validateExamples.sh @@ -25,7 +25,4 @@ runGradle issues package runGradle notepad package runGradle todoapp-lite package runGradle visual-effects package -runGradle web-compose-bird build -runGradle web-landing build -runGradle web-with-react build runGradle widgets-gallery package diff --git a/examples/validateExamplesWithJs.sh b/examples/validateExamplesWithJs.sh new file mode 100644 index 0000000000..30957744fe --- /dev/null +++ b/examples/validateExamplesWithJs.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Script to build most of the examples, to verify if they can compile. +# Don't add examples, which don't depend on maven.pkg.jetbrains.space, because they won't be able to compile. + +set -euo pipefail + +if [ "$#" -ne 2 ]; then +echo "Specify Compose and Kotlin version. For example: ./validateExamplesWithJs.sh 1.1.1 1.6.10" +exit 1 +fi +COMPOSE_VERSION=$1 +KOTLIN_VERSION=$2 + + +runGradle() { + pushd $1 + ./gradlew $2 -Pcompose.version=$COMPOSE_VERSION -Pkotlin.version=$KOTLIN_VERSION + popd +} + +runGradle web-compose-bird build +runGradle web-landing build +runGradle web-with-react build diff --git a/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt b/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt index ce59fc0ba6..1564f73c14 100644 --- a/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt +++ b/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt @@ -15,10 +15,6 @@ 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 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 = diff --git a/gradle-plugins/compose/build.gradle.kts b/gradle-plugins/compose/build.gradle.kts index d4a1efd661..0bc5c7f91a 100644 --- a/gradle-plugins/compose/build.gradle.kts +++ b/gradle-plugins/compose/build.gradle.kts @@ -29,7 +29,6 @@ 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("composeCompilerVersion", BuildProperties.composeCompilerVersion(project)) fieldsToGenerate.put("composeGradlePluginVersion", BuildProperties.deployVersion(project)) } tasks.named("compileKotlin") { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatability.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatability.kt new file mode 100644 index 0000000000..06e16e85fe --- /dev/null +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatability.kt @@ -0,0 +1,19 @@ +package org.jetbrains.compose + +import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType + +internal object ComposeCompilerCompatability { + fun compilerVersionFor(kotlinVersion: String): ComposeCompilerVersion? = when (kotlinVersion) { + "1.7.10" -> ComposeCompilerVersion("1.3.0-alpha01") + "1.7.20" -> ComposeCompilerVersion( + "1.3.2-alpha01", + unsupportedPlatforms = setOf(KotlinPlatformType.js) + ) + else -> null + } +} + +internal data class ComposeCompilerVersion( + val version: String, + val unsupportedPlatforms: Set = emptySet() +) 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 e33c1628f3..d2855675c3 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 @@ -13,13 +13,18 @@ import org.jetbrains.kotlin.gradle.plugin.* import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin { - private var composeCompilerArtifactProvider = ComposeCompilerArtifactProvider { null } + private lateinit var composeCompilerArtifactProvider: ComposeCompilerArtifactProvider 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 } + + composeCompilerArtifactProvider = ComposeCompilerArtifactProvider( + kotlinVersion = target.getKotlinPluginVersion() + ) { + composeExt.kotlinCompilerPlugin.orNull + } } } @@ -52,6 +57,7 @@ class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin { override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider> { val target = kotlinCompilation.target + composeCompilerArtifactProvider.checkTargetSupported(target) return target.project.provider { platformPluginOptions[target.platformType] ?: emptyList() } 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 index 4e3ea64f49..7a49001bda 100644 --- 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 @@ -5,33 +5,67 @@ package org.jetbrains.compose.internal -import org.jetbrains.compose.ComposeBuildConfig +import org.jetbrains.compose.ComposeCompilerCompatability +import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType +import org.jetbrains.kotlin.gradle.plugin.KotlinTarget import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact -internal class ComposeCompilerArtifactProvider(private val customPluginString: () -> String?) { +private const val KOTLIN_COMPATABILITY_LINK = + "https://github.com/JetBrains/compose-jb/blob/master/VERSIONING.md#kotlin-compatibility" + +internal class ComposeCompilerArtifactProvider( + private val kotlinVersion: String, + customPluginString: () -> String? +) { + fun checkTargetSupported(target: KotlinTarget) { + require(!unsupportedPlatforms.contains(target.platformType)) { + "This version of Compose Multiplatform doesn't support Kotlin " + + "$kotlinVersion for ${target.platformType} target. " + + "Please see $KOTLIN_COMPATABILITY_LINK " + + "to know the latest supported version of Kotlin." + } + } + + private var unsupportedPlatforms: Set = emptySet() + 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) + + init { + val customPlugin = customPluginString() + val customCoordinates = customPlugin?.split(":") + when (customCoordinates?.size) { + null -> { + val version = requireNotNull( + ComposeCompilerCompatability.compilerVersionFor(kotlinVersion) + ) { + "This version of Compose Multiplatform doesn't support Kotlin " + + "$kotlinVersion. " + + "Please see $KOTLIN_COMPATABILITY_LINK " + + "to know the latest supported version of Kotlin." } - 3 -> DefaultCompiler.pluginArtifact.copy( - groupId = customCoordinates[0], - artifactId = customCoordinates[1], - version = customCoordinates[2] + + compilerArtifact = DefaultCompiler.pluginArtifact( + version = version.version ) - else -> error(""" + unsupportedPlatforms = version.unsupportedPlatforms + } + 1 -> { + val customVersion = customCoordinates[0] + check(customVersion.isNotBlank()) { "'compose.kotlinCompilerPlugin' cannot be blank!" } + compilerArtifact = DefaultCompiler.pluginArtifact(version = customVersion) + } + 3 -> compilerArtifact = DefaultCompiler.pluginArtifact( + version = customCoordinates[2], + groupId = customCoordinates[0], + artifactId = customCoordinates[1], + ) + else -> error(""" Illegal format of 'compose.kotlinCompilerPlugin' property. Expected format: either '' or '::' Actual value: '$customPlugin' """.trimIndent()) - } } + } val compilerHostedArtifact: SubpluginArtifact get() = compilerArtifact.run { @@ -47,10 +81,13 @@ internal class ComposeCompilerArtifactProvider(private val customPluginString: ( 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) + fun pluginArtifact( + version: String, + groupId: String = GROUP_ID, + artifactId: String = ARTIFACT_ID, + ): SubpluginArtifact = + SubpluginArtifact(groupId = groupId, artifactId = artifactId, version = version) } } diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt index 0656251938..98cf5e7949 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt @@ -22,7 +22,14 @@ import org.junit.jupiter.api.Test class GradlePluginTest : GradlePluginTestBase() { @Test fun jsMppIsNotBroken() = - with(testProject(TestProjects.jsMpp)) { + with( + testProject( + TestProjects.jsMpp, + testEnvironment = defaultTestEnvironment.copy( + kotlinVersion = TestProperties.composeJsCompilerCompatibleKotlinVersion + ) + ) + ) { gradle(":compileKotlinJs").build().checks { check -> check.taskOutcome(":compileKotlinJs", TaskOutcome.SUCCESS) } diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/KotlinCompatabilityTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/KotlinCompatabilityTest.kt new file mode 100644 index 0000000000..2d45460d4b --- /dev/null +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/KotlinCompatabilityTest.kt @@ -0,0 +1,56 @@ +/* + * 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.integration + +import org.gradle.testkit.runner.TaskOutcome +import org.gradle.testkit.runner.UnexpectedBuildFailure +import org.jetbrains.compose.test.utils.GradlePluginTestBase +import org.jetbrains.compose.test.utils.TestProjects +import org.jetbrains.compose.test.utils.checks +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows + +class KotlinCompatabilityTest : GradlePluginTestBase() { + @Test + fun testKotlinMpp_1_7_10() = testMpp("1.7.10") + + @Test + fun testKotlinJsMpp_1_7_10() = testJsMpp("1.7.10") + + @Test + fun testKotlinMpp_1_7_20() = testMpp("1.7.20") + + @Test + fun testKotlinJsMpp_1_7_20() { + assertThrows { + testJsMpp("1.7.20") + } + } + + private fun testMpp(kotlinVersion: String) = with( + testProject( + TestProjects.mpp, + testEnvironment = defaultTestEnvironment.copy(kotlinVersion = kotlinVersion) + ) + ) { + val logLine = "Kotlin MPP app is running!" + gradle("run").build().checks { check -> + check.taskOutcome(":run", TaskOutcome.SUCCESS) + check.logContains(logLine) + } + } + + private fun testJsMpp(kotlinVersion: String) = with( + testProject( + TestProjects.jsMpp, + testEnvironment = defaultTestEnvironment.copy(kotlinVersion = kotlinVersion) + ) + ) { + gradle(":compileKotlinJs").build().checks { check -> + check.taskOutcome(":compileKotlinJs", TaskOutcome.SUCCESS) + } + } +} 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 index 9c848d2db5..7648fe1bcc 100644 --- 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 @@ -18,7 +18,7 @@ internal class ComposeCompilerArtifactProviderTest { fun defaultCompilerArtifact() { assertArtifactEquals( Expected.jbCompiler, - Actual.compiler(null) + Actual.compiler(null, TestProperties.composeCompilerCompatibleKotlinVersion) ) } @@ -26,7 +26,7 @@ internal class ComposeCompilerArtifactProviderTest { fun defaultCompilerHostedArtifact() { assertArtifactEquals( Expected.jbCompilerHosted, - Actual.compilerHosted(null) + Actual.compilerHosted(null, TestProperties.composeCompilerCompatibleKotlinVersion) ) } @@ -34,7 +34,7 @@ internal class ComposeCompilerArtifactProviderTest { fun customVersion() { assertArtifactEquals( Expected.jbCompiler.copy(version = "10.20.30"), - Actual.compiler("10.20.30") + Actual.compiler("10.20.30", TestProperties.composeCompilerCompatibleKotlinVersion) ) } @@ -42,7 +42,10 @@ internal class ComposeCompilerArtifactProviderTest { fun customCompiler() { assertArtifactEquals( Expected.googleCompiler.copy(version = "1.3.1"), - Actual.compiler("androidx.compose.compiler:compiler:1.3.1") + Actual.compiler( + "androidx.compose.compiler:compiler:1.3.1", + TestProperties.androidxCompilerCompatibleKotlinVersion + ) ) } @@ -51,7 +54,10 @@ internal class ComposeCompilerArtifactProviderTest { // 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") + Actual.compilerHosted( + "androidx.compose.compiler:compiler:1.3.1", + TestProperties.composeCompilerCompatibleKotlinVersion + ) ) } @@ -64,7 +70,7 @@ internal class ComposeCompilerArtifactProviderTest { private fun testIllegalCompiler(pluginString: String?) { try { - Actual.compiler(pluginString) + Actual.compiler(pluginString, "") } catch (e: Exception) { return } @@ -73,11 +79,11 @@ internal class ComposeCompilerArtifactProviderTest { } object Actual { - fun compiler(pluginString: String?) = - ComposeCompilerArtifactProvider { pluginString }.compilerArtifact + fun compiler(pluginString: String?, kotlinVersion: String) = + ComposeCompilerArtifactProvider(kotlinVersion) { pluginString }.compilerArtifact - fun compilerHosted(pluginString: String?) = - ComposeCompilerArtifactProvider { pluginString }.compilerHostedArtifact + fun compilerHosted(pluginString: String?, kotlinVersion: String) = + ComposeCompilerArtifactProvider(kotlinVersion) { pluginString }.compilerHostedArtifact } object Expected { diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradlePluginTestBase.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradlePluginTestBase.kt index 17bdfaa0fc..9b5d0ba48b 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradlePluginTestBase.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradlePluginTestBase.kt @@ -17,7 +17,7 @@ abstract class GradlePluginTestBase { val defaultAndroidxCompilerEnvironment: TestEnvironment get() = defaultTestEnvironment.copy( - kotlinVersion = TestKotlinVersion.AndroidxCompatible, + kotlinVersion = TestKotlinVersions.AndroidxCompatible, composeCompilerArtifact = "androidx.compose.compiler:compiler:${TestProperties.androidxCompilerVersion}" ) 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/TestKotlinVersions.kt similarity index 50% rename from gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersion.kt rename to gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersions.kt index f2b24d983f..e1f37b09f4 100644 --- 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/TestKotlinVersions.kt @@ -5,8 +5,7 @@ package org.jetbrains.compose.test.utils -@Suppress("EnumEntryName") -enum class TestKotlinVersion(val versionString: String) { - Default(TestProperties.composeCompilerCompatibleKotlinVersion), - AndroidxCompatible(TestProperties.androidxCompilerCompatibleKotlinVersion) +object TestKotlinVersions { + val Default = TestProperties.composeCompilerCompatibleKotlinVersion + val AndroidxCompatible = TestProperties.androidxCompilerCompatibleKotlinVersion } \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt index dc775b35ce..f02c612027 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt @@ -11,7 +11,7 @@ import java.io.File data class TestEnvironment( val workingDir: File, - val kotlinVersion: TestKotlinVersion = TestKotlinVersion.Default, + val kotlinVersion: String = TestKotlinVersions.Default, val composeGradlePluginVersion: String = TestProperties.composeGradlePluginVersion, val composeCompilerArtifact: String? = null ) @@ -41,7 +41,7 @@ class TestProject( val origContent = orig.readText() var newContent = origContent .replace("COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER", testEnvironment.composeGradlePluginVersion) - .replace("KOTLIN_VERSION_PLACEHOLDER", testEnvironment.kotlinVersion.versionString) + .replace("KOTLIN_VERSION_PLACEHOLDER", testEnvironment.kotlinVersion) if (testEnvironment.composeCompilerArtifact != null) { newContent = newContent.replace("COMPOSE_COMPILER_ARTIFACT_PLACEHOLDER", testEnvironment.composeCompilerArtifact) } 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 index 84814a6af7..fe857842f8 100644 --- 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 @@ -7,10 +7,13 @@ package org.jetbrains.compose.test.utils object TestProperties { val composeCompilerVersion: String - get() = notNullSystemProperty("compose.compiler.version") + get() = notNullSystemProperty("compose.tests.compiler.version") val composeCompilerCompatibleKotlinVersion: String - get() = notNullSystemProperty("compose.compiler.compatible.kotlin.version") + get() = notNullSystemProperty("compose.tests.compiler.compatible.kotlin.version") + + val composeJsCompilerCompatibleKotlinVersion: String + get() = notNullSystemProperty("compose.tests.js.compiler.compatible.kotlin.version") val androidxCompilerVersion: String get() = notNullSystemProperty("compose.tests.androidx.compiler.version") diff --git a/gradle-plugins/gradle.properties b/gradle-plugins/gradle.properties index b604dcff64..e6a53ad112 100644 --- a/gradle-plugins/gradle.properties +++ b/gradle-plugins/gradle.properties @@ -1,13 +1,16 @@ org.gradle.parallel=true kotlin.code.style=official -# __LATEST_COMPOSE_RELEASE_VERSION__ # Default version of Compose Libraries used by Gradle plugin compose.version=1.2.0-beta02 -# Default version of Compose Compiler used by Gradle plugin -compose.compiler.version=1.3.2-alpha01 -# Default version of Kotlin compatible with compose.compiler.version -compose.compiler.compatible.kotlin.version=1.7.20 +# The latest version of Compose Compiler used by Gradle plugin. Used only in tests. +compose.tests.compiler.version=1.3.2-alpha01 +# The latest version of Kotlin compatible with compose.tests.compiler.version. Used only in tests. +compose.tests.compiler.compatible.kotlin.version=1.7.20 +# The latest version of Kotlin compatible with compose.tests.compiler.version for JS target. Used only on CI. +compose.tests.js.compiler.compatible.kotlin.version=1.7.10 +# Version of Compose Compiler published by Google. +# Used to check if our plugin is compatible with it. # 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 diff --git a/tutorials/checker/build.gradle.kts b/tutorials/checker/build.gradle.kts index b1ba6ef0e7..37e8f24dd8 100644 --- a/tutorials/checker/build.gradle.kts +++ b/tutorials/checker/build.gradle.kts @@ -70,7 +70,7 @@ fun maybeFail(tutorial: String, message: String) { } @OptIn(ExperimentalStdlibApi::class) -fun checkDirs(dirs: List, template: String, buildCmd: String = "build") { +fun checkDirs(dirs: List, template: String, buildCmd: String, kotlinVersion: String?) { val snippets = findSnippets(dirs) snippets.forEachIndexed { index, snippet -> println("process snippet $index at ${snippet.file}:${snippet.lineNumber} with $template") @@ -86,7 +86,7 @@ fun checkDirs(dirs: List, template: String, buildCmd: String = "build") add(buildCmd) - project.findProperty("kotlin.version")?.also { + kotlinVersion?.also { add("-Pkotlin.version=$it") } project.findProperty("compose.version")?.also { @@ -110,7 +110,7 @@ fun checkDirs(dirs: List, template: String, buildCmd: String = "build") // NOTICE: currently we use a bit hacky approach, when "```kotlin" marks code that shall be checked, while "``` kotlin" // with whitespace marks code that shall not be checked. tasks.register("check") { - val checks = CheckSpec.createCheckSpecs( + val checks = createCheckSpecs( checkTargets = (project.property("CHECK_TARGET")?.toString() ?: "all").toLowerCase() ) @@ -129,29 +129,36 @@ tasks.register("check") { checkDirs( dirs = subdirs.map { "${check.dir}/$it" }, template = check.template, - buildCmd = check.gradleCmd + buildCmd = check.gradleCmd, + kotlinVersion = check.kotlinVersion ) } } } -data class CheckSpec( - val gradleCmd: String, - val dir: String, - val template: String -) { - companion object { - fun desktop() = CheckSpec(gradleCmd = "build", dir = ".", template = "desktop-template") - fun web() = CheckSpec(gradleCmd = "compileKotlinJs", dir = "Web", template = "web-template") - fun all() = listOf(desktop(), web()) +fun createCheckSpecs(checkTargets: String = "all"): List { + fun desktop() = CheckSpec( + gradleCmd = "build", dir = ".", template = "desktop-template", + kotlinVersion = project.findProperty("kotlin.version")?.toString() + ) + fun web() = CheckSpec( + gradleCmd = "compileKotlinJs", dir = "Web", template = "web-template", + kotlinVersion = project.findProperty("kotlin.js.version")?.toString() ?: + project.findProperty("kotlin.version")?.toString() + ) + fun all() = listOf(desktop(), web()) - fun createCheckSpecs(checkTargets: String = "all"): List { - return when (checkTargets) { - "web" -> listOf(web()) - "desktop" -> listOf(desktop()) - else -> all() - } - } + return when (checkTargets) { + "web" -> listOf(web()) + "desktop" -> listOf(desktop()) + else -> all() } } + +data class CheckSpec( + val gradleCmd: String, + val dir: String, + val template: String, + val kotlinVersion: String? +) \ No newline at end of file