Browse Source

Merge remote-tracking branch 'origin/master' into release/1.2

# Conflicts:
#	compose/frameworks/support
#	web/gradle.properties
pull/2382/head
Igor Demin 2 years ago
parent
commit
86bb7453d1
  1. 12
      README.md
  2. 19
      VERSIONING.md
  3. 3
      examples/validateExamples.sh
  4. 24
      examples/validateExamplesWithJs.sh
  5. 8
      gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt
  6. 3
      gradle-plugins/compose/build.gradle.kts
  7. 19
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatability.kt
  8. 10
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt
  9. 54
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt
  10. 4
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt
  11. 59
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/ComposeCompilerArtifactProvider.kt
  12. 9
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt
  13. 56
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/KotlinCompatabilityTest.kt
  14. 26
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/ComposeCompilerArtifactProviderTest.kt
  15. 2
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradlePluginTestBase.kt
  16. 7
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersions.kt
  17. 4
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt
  18. 7
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt
  19. 13
      gradle-plugins/gradle.properties
  20. 2
      tutorials/Native_distributions_and_local_execution/README.md
  21. 37
      tutorials/checker/build.gradle.kts
  22. 2
      web/build.gradle.kts
  23. 2
      web/compose-compiler-integration/README.md
  24. 4
      web/compose-compiler-integration/build.gradle.kts
  25. 4
      web/compose-compiler-integration/main-template/settings.gradle.kts
  26. 3
      web/gradle.properties
  27. 2
      web/settings.gradle.kts

12
README.md

@ -4,10 +4,9 @@
# Compose Multiplatform, by JetBrains # Compose Multiplatform, by JetBrains
![](artwork/readme/apps.png) ![](artwork/readme/apps.png)
Compose Kotlin UI framework port for desktop platforms (macOS, Linux, Windows) and Web, components outside of the core Compose repository 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).
at 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 ## Tutorials
### Compose for Desktop ### Compose for Desktop
@ -71,6 +70,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) * [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 * [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)

19
FEATURES.md → VERSIONING.md

@ -6,8 +6,6 @@
* Linux (x86-64, arm64) * Linux (x86-64, arm64)
* Web browsers * Web browsers
Follow individual tutorials to understand how to use particular feature.
### Limitations ### Limitations
Following limitations apply to 1.0 release. Following limitations apply to 1.0 release.
@ -23,12 +21,13 @@ Knowing issues on older versions:
### Kotlin compatibility ### Kotlin compatibility
Compose version | Kotlin 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.
1.0.0+ | 1.5.31 Starting from 1.2.0, Compose Multiplatform supports multiple versions of Kotlin.
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). 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)

3
examples/validateExamples.sh

@ -25,7 +25,4 @@ runGradle issues package
runGradle notepad package runGradle notepad package
runGradle todoapp-lite package runGradle todoapp-lite package
runGradle visual-effects package runGradle visual-effects package
runGradle web-compose-bird build
runGradle web-landing build
runGradle web-with-react build
runGradle widgets-gallery package runGradle widgets-gallery package

24
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

8
gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt

@ -15,10 +15,6 @@ object BuildProperties {
fun composeVersion(project: Project): String = fun composeVersion(project: Project): String =
System.getenv("COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION") System.getenv("COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION")
?: project.findProperty("compose.version") as String ?: 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 = fun testsAndroidxCompilerVersion(project: Project): String =
project.findProperty("compose.tests.androidx.compiler.version") as String project.findProperty("compose.tests.androidx.compiler.version") as String
fun testsAndroidxCompilerCompatibleVersion(project: Project): String = fun testsAndroidxCompilerCompatibleVersion(project: Project): String =
@ -26,8 +22,4 @@ object BuildProperties {
fun deployVersion(project: Project): String = fun deployVersion(project: Project): String =
System.getenv("COMPOSE_GRADLE_PLUGIN_VERSION") System.getenv("COMPOSE_GRADLE_PLUGIN_VERSION")
?: project.findProperty("deploy.version") as String ?: project.findProperty("deploy.version") as String
fun experimentalOELPublication(project: Project): Boolean =
project.findProperty("oel.publication") == "true"
fun oelAndroidXVersion(project: Project): String? =
project.findProperty("oel.androidx.version") as String?
} }

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

@ -29,10 +29,7 @@ val buildConfig = tasks.register("buildConfig", GenerateBuildConfig::class.java)
classFqName.set("org.jetbrains.compose.ComposeBuildConfig") classFqName.set("org.jetbrains.compose.ComposeBuildConfig")
generatedOutputDir.set(buildConfigDir) generatedOutputDir.set(buildConfigDir)
fieldsToGenerate.put("composeVersion", BuildProperties.composeVersion(project)) fieldsToGenerate.put("composeVersion", BuildProperties.composeVersion(project))
fieldsToGenerate.put("composeCompilerVersion", BuildProperties.composeCompilerVersion(project))
fieldsToGenerate.put("composeGradlePluginVersion", BuildProperties.deployVersion(project)) fieldsToGenerate.put("composeGradlePluginVersion", BuildProperties.deployVersion(project))
fieldsToGenerate.put("experimentalOELPublication", BuildProperties.experimentalOELPublication(project))
fieldsToGenerate.put("oelAndroidXVersion", BuildProperties.oelAndroidXVersion(project).orEmpty())
} }
tasks.named("compileKotlin") { tasks.named("compileKotlin") {
dependsOn(buildConfig) dependsOn(buildConfig)

19
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<KotlinPlatformType> = emptySet()
)

10
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 import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin { class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin {
private var composeCompilerArtifactProvider = ComposeCompilerArtifactProvider { null } private lateinit var composeCompilerArtifactProvider: ComposeCompilerArtifactProvider
override fun apply(target: Project) { override fun apply(target: Project) {
super.apply(target) super.apply(target)
target.plugins.withType(ComposePlugin::class.java) { target.plugins.withType(ComposePlugin::class.java) {
val composeExt = target.extensions.getByType(ComposeExtension::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<List<SubpluginOption>> { override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider<List<SubpluginOption>> {
val target = kotlinCompilation.target val target = kotlinCompilation.target
composeCompilerArtifactProvider.checkTargetSupported(target)
return target.project.provider { return target.project.provider {
platformPluginOptions[target.platformType] ?: emptyList() platformPluginOptions[target.platformType] ?: emptyList()
} }

54
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt

@ -69,60 +69,6 @@ class ComposePlugin : Plugin<Project> {
} }
} }
//redirecting all android artifacts to androidx.compose
project.dependencies.modules {
if (!androidExtension.useAndroidX && !ComposeBuildConfig.experimentalOELPublication) {
// Replace 'androidx.compose' artifacts by 'org.jetbrains.compose' artifacts.
// It is needed, because 'org.jetbrains.compose' artifacts are the same artifacts as 'androidx.compose'
// (but with different version).
// And Gradle will throw an error when it cannot determine which class from which artifact should it use.
//
// Note that we don't provide a configuration parameter to disable dependency replacement,
// because without replacement, gradle will fail anyway because classpath contains two incompatible artifacts.
//
// We should define all replacements, even for transitive dependencies.
// For example, a library can depend on androidx.compose.foundation:foundation-layout
//
// List of all org.jetbrains.compose libraries is here:
// https://maven.pkg.jetbrains.space/public/p/compose/dev/org/jetbrains/compose/
//
// (use ./gradle printAllAndroidxReplacements to know what dependencies should be here)
//
// It is temporarily solution until we will be publishing all MPP artifacts in Google Maven repository.
// Or align versions with androidx artifacts and point MPP-android artifacts to androidx artifacts (is it possible?)
listOf(
"androidx.compose.animation:animation",
"androidx.compose.animation:animation-core",
"androidx.compose.animation:animation-graphics",
"androidx.compose.compiler:compiler",
"androidx.compose.compiler:compiler-hosted",
"androidx.compose.foundation:foundation",
"androidx.compose.foundation:foundation-layout",
"androidx.compose.material:material",
"androidx.compose.material:material-icons-core",
"androidx.compose.material:material-icons-extended",
"androidx.compose.material:material-ripple",
"androidx.compose.material:material3",
"androidx.compose.runtime:runtime",
"androidx.compose.runtime:runtime-saveable",
"androidx.compose.ui:ui",
"androidx.compose.ui:ui-geometry",
"androidx.compose.ui:ui-graphics",
"androidx.compose.ui:ui-test",
"androidx.compose.ui:ui-test-junit4",
"androidx.compose.ui:ui-text",
"androidx.compose.ui:ui-unit",
"androidx.compose.ui:ui-util"
).forEach() { module ->
it.replaceAndroidx(
module,
module.replace("androidx.compose", "org.jetbrains.compose")
)
}
}
}
val overrideDefaultJvmTarget = ComposeProperties.overrideKotlinJvmTarget(project.providers).get() val overrideDefaultJvmTarget = ComposeProperties.overrideKotlinJvmTarget(project.providers).get()
project.tasks.withType(KotlinCompile::class.java) { project.tasks.withType(KotlinCompile::class.java) {
it.kotlinOptions.apply { it.kotlinOptions.apply {

4
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt

@ -579,8 +579,8 @@ abstract class AbstractJPackageTask @Inject constructor(
val packageVersion = packageVersion.get()!! val packageVersion = packageVersion.get()!!
plist[PlistKeys.CFBundleShortVersionString] = packageVersion plist[PlistKeys.CFBundleShortVersionString] = packageVersion
// If building for the App Store, use "utilities" as default just like jpackage. // If building for the App Store, use "utilities" as default just like jpackage.
val category = macAppCategory.orNull ?: (if (macAppStore.orNull == true) "utilities" else null) val category = macAppCategory.orNull ?: (if (macAppStore.orNull == true) "public.app-category.utilities" else null)
plist[PlistKeys.LSApplicationCategoryType] = category?.let { "public.app-category.$it" } ?: "Unknown" plist[PlistKeys.LSApplicationCategoryType] = category ?: "Unknown"
val packageBuildVersion = packageBuildVersion.orNull ?: packageVersion val packageBuildVersion = packageBuildVersion.orNull ?: packageVersion
plist[PlistKeys.CFBundleVersion] = packageBuildVersion plist[PlistKeys.CFBundleVersion] = packageBuildVersion
val year = Calendar.getInstance().get(Calendar.YEAR) val year = Calendar.getInstance().get(Calendar.YEAR)

59
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/ComposeCompilerArtifactProvider.kt

@ -5,25 +5,59 @@
package org.jetbrains.compose.internal 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 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<KotlinPlatformType> = emptySet()
val compilerArtifact: SubpluginArtifact val compilerArtifact: SubpluginArtifact
get() {
init {
val customPlugin = customPluginString() val customPlugin = customPluginString()
val customCoordinates = customPlugin?.split(":") val customCoordinates = customPlugin?.split(":")
return when (customCoordinates?.size) { when (customCoordinates?.size) {
null -> DefaultCompiler.pluginArtifact 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."
}
compilerArtifact = DefaultCompiler.pluginArtifact(
version = version.version
)
unsupportedPlatforms = version.unsupportedPlatforms
}
1 -> { 1 -> {
val customVersion = customCoordinates[0] val customVersion = customCoordinates[0]
check(customVersion.isNotBlank()) { "'compose.kotlinCompilerPlugin' cannot be blank!" } check(customVersion.isNotBlank()) { "'compose.kotlinCompilerPlugin' cannot be blank!" }
DefaultCompiler.pluginArtifact.copy(version = customVersion) compilerArtifact = DefaultCompiler.pluginArtifact(version = customVersion)
} }
3 -> DefaultCompiler.pluginArtifact.copy( 3 -> compilerArtifact = DefaultCompiler.pluginArtifact(
version = customCoordinates[2],
groupId = customCoordinates[0], groupId = customCoordinates[0],
artifactId = customCoordinates[1], artifactId = customCoordinates[1],
version = customCoordinates[2]
) )
else -> error(""" else -> error("""
Illegal format of 'compose.kotlinCompilerPlugin' property. Illegal format of 'compose.kotlinCompilerPlugin' property.
@ -47,10 +81,13 @@ internal class ComposeCompilerArtifactProvider(private val customPluginString: (
const val GROUP_ID = "org.jetbrains.compose.compiler" const val GROUP_ID = "org.jetbrains.compose.compiler"
const val ARTIFACT_ID = "compiler" const val ARTIFACT_ID = "compiler"
const val HOSTED_ARTIFACT_ID = "compiler-hosted" const val HOSTED_ARTIFACT_ID = "compiler-hosted"
const val VERSION = ComposeBuildConfig.composeCompilerVersion
val pluginArtifact: SubpluginArtifact fun pluginArtifact(
get() = SubpluginArtifact(groupId = GROUP_ID, artifactId = ARTIFACT_ID, version = VERSION) version: String,
groupId: String = GROUP_ID,
artifactId: String = ARTIFACT_ID,
): SubpluginArtifact =
SubpluginArtifact(groupId = groupId, artifactId = artifactId, version = version)
} }
} }

9
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() { class GradlePluginTest : GradlePluginTestBase() {
@Test @Test
fun jsMppIsNotBroken() = fun jsMppIsNotBroken() =
with(testProject(TestProjects.jsMpp)) { with(
testProject(
TestProjects.jsMpp,
testEnvironment = defaultTestEnvironment.copy(
kotlinVersion = TestProperties.composeJsCompilerCompatibleKotlinVersion
)
)
) {
gradle(":compileKotlinJs").build().checks { check -> gradle(":compileKotlinJs").build().checks { check ->
check.taskOutcome(":compileKotlinJs", TaskOutcome.SUCCESS) check.taskOutcome(":compileKotlinJs", TaskOutcome.SUCCESS)
} }

56
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<UnexpectedBuildFailure> {
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)
}
}
}

26
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/ComposeCompilerArtifactProviderTest.kt

@ -18,7 +18,7 @@ internal class ComposeCompilerArtifactProviderTest {
fun defaultCompilerArtifact() { fun defaultCompilerArtifact() {
assertArtifactEquals( assertArtifactEquals(
Expected.jbCompiler, Expected.jbCompiler,
Actual.compiler(null) Actual.compiler(null, TestProperties.composeCompilerCompatibleKotlinVersion)
) )
} }
@ -26,7 +26,7 @@ internal class ComposeCompilerArtifactProviderTest {
fun defaultCompilerHostedArtifact() { fun defaultCompilerHostedArtifact() {
assertArtifactEquals( assertArtifactEquals(
Expected.jbCompilerHosted, Expected.jbCompilerHosted,
Actual.compilerHosted(null) Actual.compilerHosted(null, TestProperties.composeCompilerCompatibleKotlinVersion)
) )
} }
@ -34,7 +34,7 @@ internal class ComposeCompilerArtifactProviderTest {
fun customVersion() { fun customVersion() {
assertArtifactEquals( assertArtifactEquals(
Expected.jbCompiler.copy(version = "10.20.30"), 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() { fun customCompiler() {
assertArtifactEquals( assertArtifactEquals(
Expected.googleCompiler.copy(version = "1.3.1"), 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 // check that we don't replace artifactId for non-jb compiler
assertArtifactEquals( assertArtifactEquals(
Expected.googleCompiler.copy(version = "1.3.1"), 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?) { private fun testIllegalCompiler(pluginString: String?) {
try { try {
Actual.compiler(pluginString) Actual.compiler(pluginString, "")
} catch (e: Exception) { } catch (e: Exception) {
return return
} }
@ -73,11 +79,11 @@ internal class ComposeCompilerArtifactProviderTest {
} }
object Actual { object Actual {
fun compiler(pluginString: String?) = fun compiler(pluginString: String?, kotlinVersion: String) =
ComposeCompilerArtifactProvider { pluginString }.compilerArtifact ComposeCompilerArtifactProvider(kotlinVersion) { pluginString }.compilerArtifact
fun compilerHosted(pluginString: String?) = fun compilerHosted(pluginString: String?, kotlinVersion: String) =
ComposeCompilerArtifactProvider { pluginString }.compilerHostedArtifact ComposeCompilerArtifactProvider(kotlinVersion) { pluginString }.compilerHostedArtifact
} }
object Expected { object Expected {

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

@ -17,7 +17,7 @@ abstract class GradlePluginTestBase {
val defaultAndroidxCompilerEnvironment: TestEnvironment val defaultAndroidxCompilerEnvironment: TestEnvironment
get() = defaultTestEnvironment.copy( get() = defaultTestEnvironment.copy(
kotlinVersion = TestKotlinVersion.AndroidxCompatible, kotlinVersion = TestKotlinVersions.AndroidxCompatible,
composeCompilerArtifact = "androidx.compose.compiler:compiler:${TestProperties.androidxCompilerVersion}" composeCompilerArtifact = "androidx.compose.compiler:compiler:${TestProperties.androidxCompilerVersion}"
) )

7
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersion.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersions.kt

@ -5,8 +5,7 @@
package org.jetbrains.compose.test.utils package org.jetbrains.compose.test.utils
@Suppress("EnumEntryName") object TestKotlinVersions {
enum class TestKotlinVersion(val versionString: String) { val Default = TestProperties.composeCompilerCompatibleKotlinVersion
Default(TestProperties.composeCompilerCompatibleKotlinVersion), val AndroidxCompatible = TestProperties.androidxCompilerCompatibleKotlinVersion
AndroidxCompatible(TestProperties.androidxCompilerCompatibleKotlinVersion)
} }

4
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt

@ -11,7 +11,7 @@ import java.io.File
data class TestEnvironment( data class TestEnvironment(
val workingDir: File, val workingDir: File,
val kotlinVersion: TestKotlinVersion = TestKotlinVersion.Default, val kotlinVersion: String = TestKotlinVersions.Default,
val composeGradlePluginVersion: String = TestProperties.composeGradlePluginVersion, val composeGradlePluginVersion: String = TestProperties.composeGradlePluginVersion,
val composeCompilerArtifact: String? = null val composeCompilerArtifact: String? = null
) )
@ -41,7 +41,7 @@ class TestProject(
val origContent = orig.readText() val origContent = orig.readText()
var newContent = origContent var newContent = origContent
.replace("COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER", testEnvironment.composeGradlePluginVersion) .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) { if (testEnvironment.composeCompilerArtifact != null) {
newContent = newContent.replace("COMPOSE_COMPILER_ARTIFACT_PLACEHOLDER", testEnvironment.composeCompilerArtifact) newContent = newContent.replace("COMPOSE_COMPILER_ARTIFACT_PLACEHOLDER", testEnvironment.composeCompilerArtifact)
} }

7
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 { object TestProperties {
val composeCompilerVersion: String val composeCompilerVersion: String
get() = notNullSystemProperty("compose.compiler.version") get() = notNullSystemProperty("compose.tests.compiler.version")
val composeCompilerCompatibleKotlinVersion: String 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 val androidxCompilerVersion: String
get() = notNullSystemProperty("compose.tests.androidx.compiler.version") get() = notNullSystemProperty("compose.tests.androidx.compiler.version")

13
gradle-plugins/gradle.properties

@ -1,13 +1,16 @@
org.gradle.parallel=true org.gradle.parallel=true
kotlin.code.style=official kotlin.code.style=official
# __LATEST_COMPOSE_RELEASE_VERSION__
# Default version of Compose Libraries used by Gradle plugin # Default version of Compose Libraries used by Gradle plugin
compose.version=1.2.0-beta02 compose.version=1.2.0-beta02
# Default version of Compose Compiler used by Gradle plugin # The latest version of Compose Compiler used by Gradle plugin. Used only in tests.
compose.compiler.version=1.3.2-alpha01 compose.tests.compiler.version=1.3.2-alpha01
# Default version of Kotlin compatible with compose.compiler.version # The latest version of Kotlin compatible with compose.tests.compiler.version. Used only in tests.
compose.compiler.compatible.kotlin.version=1.7.20 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 # https://developer.android.com/jetpack/androidx/releases/compose-kotlin
compose.tests.androidx.compiler.version=1.3.1 compose.tests.androidx.compiler.version=1.3.1
compose.tests.androidx.compiler.compatible.kotlin.version=1.7.10 compose.tests.androidx.compiler.compatible.kotlin.version=1.7.10

2
tutorials/Native_distributions_and_local_execution/README.md

@ -447,7 +447,7 @@ The following platform-specific options are available
for details; for details;
* `appStore = true` — build and sign for the Apple App Store. Requires at least JDK 17; * `appStore = true` — build and sign for the Apple App Store. Requires at least JDK 17;
* `appCategory` — category of the app for the Apple App Store. * `appCategory` — category of the app for the Apple App Store.
Default value is `utilities` when building for the App Store, `Unknown` otherwise. Default value is `public.app-category.utilities` when building for the App Store, `Unknown` otherwise.
See [LSApplicationCategoryType](https://developer.apple.com/documentation/bundleresources/information_property_list/lsapplicationcategorytype) for a list of valid categories; See [LSApplicationCategoryType](https://developer.apple.com/documentation/bundleresources/information_property_list/lsapplicationcategorytype) for a list of valid categories;
* `entitlementsFile.set(File("PATH_TO_ENTITLEMENTS"))` — a path to file containing entitlements to use when signing. * `entitlementsFile.set(File("PATH_TO_ENTITLEMENTS"))` — a path to file containing entitlements to use when signing.
When a custom file is provided, make sure to add the entitlements that are required for Java apps. When a custom file is provided, make sure to add the entitlements that are required for Java apps.

37
tutorials/checker/build.gradle.kts

@ -70,7 +70,7 @@ fun maybeFail(tutorial: String, message: String) {
} }
@OptIn(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
fun checkDirs(dirs: List<String>, template: String, buildCmd: String = "build") { fun checkDirs(dirs: List<String>, template: String, buildCmd: String, kotlinVersion: String?) {
val snippets = findSnippets(dirs) val snippets = findSnippets(dirs)
snippets.forEachIndexed { index, snippet -> snippets.forEachIndexed { index, snippet ->
println("process snippet $index at ${snippet.file}:${snippet.lineNumber} with $template") println("process snippet $index at ${snippet.file}:${snippet.lineNumber} with $template")
@ -86,7 +86,7 @@ fun checkDirs(dirs: List<String>, template: String, buildCmd: String = "build")
add(buildCmd) add(buildCmd)
project.findProperty("kotlin.version")?.also { kotlinVersion?.also {
add("-Pkotlin.version=$it") add("-Pkotlin.version=$it")
} }
project.findProperty("compose.version")?.also { project.findProperty("compose.version")?.also {
@ -110,7 +110,7 @@ fun checkDirs(dirs: List<String>, template: String, buildCmd: String = "build")
// NOTICE: currently we use a bit hacky approach, when "```kotlin" marks code that shall be checked, while "``` kotlin" // 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. // with whitespace marks code that shall not be checked.
tasks.register("check") { tasks.register("check") {
val checks = CheckSpec.createCheckSpecs( val checks = createCheckSpecs(
checkTargets = (project.property("CHECK_TARGET")?.toString() ?: "all").toLowerCase() checkTargets = (project.property("CHECK_TARGET")?.toString() ?: "all").toLowerCase()
) )
@ -129,29 +129,36 @@ tasks.register("check") {
checkDirs( checkDirs(
dirs = subdirs.map { "${check.dir}/$it" }, dirs = subdirs.map { "${check.dir}/$it" },
template = check.template, 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 createCheckSpecs(checkTargets: String = "all"): List<CheckSpec> {
fun desktop() = CheckSpec(gradleCmd = "build", dir = ".", template = "desktop-template") fun desktop() = CheckSpec(
fun web() = CheckSpec(gradleCmd = "compileKotlinJs", dir = "Web", template = "web-template") 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 all() = listOf(desktop(), web())
fun createCheckSpecs(checkTargets: String = "all"): List<CheckSpec> {
return when (checkTargets) { return when (checkTargets) {
"web" -> listOf(web()) "web" -> listOf(web())
"desktop" -> listOf(desktop()) "desktop" -> listOf(desktop())
else -> all() else -> all()
} }
} }
}
} data class CheckSpec(
val gradleCmd: String,
val dir: String,
val template: String,
val kotlinVersion: String?
)

2
web/build.gradle.kts

@ -8,7 +8,7 @@ plugins {
kotlin("multiplatform") apply false kotlin("multiplatform") apply false
} }
val COMPOSE_WEB_VERSION: String by project val COMPOSE_WEB_VERSION: String = extra["compose.version"] as String
val COMPOSE_REPO_USERNAME: String? by project val COMPOSE_REPO_USERNAME: String? by project
val COMPOSE_REPO_KEY: String? by project val COMPOSE_REPO_KEY: String? by project
val COMPOSE_WEB_BUILD_WITH_SAMPLES = project.property("compose.web.buildSamples")!!.toString().toBoolean() val COMPOSE_WEB_BUILD_WITH_SAMPLES = project.property("compose.web.buildSamples")!!.toString().toBoolean()

2
web/compose-compiler-integration/README.md

@ -2,7 +2,7 @@ RUN from project root directory:
`./gradlew :compose-compiler-integration:checkComposeCases` `./gradlew :compose-compiler-integration:checkComposeCases`
To use specific version: To use specific version:
`./gradlew :compose-compiler-integration:checkComposeCases -PCOMPOSE_CORE_VERSION=1.0.1-rc2 -PCOMPOSE_WEB_VERSION=1.0.1-rc2 `./gradlew :compose-compiler-integration:checkComposeCases -Pcompose.version=1.2.0-beta03
To fun only filtered cases (check for contained in file path): To fun only filtered cases (check for contained in file path):
`./gradlew :compose-compiler-integration:checkComposeCases -PFILTER_CASES=CaseName` `./gradlew :compose-compiler-integration:checkComposeCases -PFILTER_CASES=CaseName`

4
web/compose-compiler-integration/build.gradle.kts

@ -61,7 +61,7 @@ fun build(
) { ) {
val isWin = System.getProperty("os.name").startsWith("Win") val isWin = System.getProperty("os.name").startsWith("Win")
val arguments = buildCmd.toMutableList().also { val arguments = buildCmd.toMutableList().also {
it.add("-PCOMPOSE_CORE_VERSION=$composeVersion") it.add("-Pcompose.version=$composeVersion")
it.add("-Pkotlin.version=$kotlinVersion") it.add("-Pkotlin.version=$kotlinVersion")
}.toTypedArray() }.toTypedArray()
@ -176,7 +176,7 @@ fun runCasesInDirectory(
tasks.register("checkComposeCases") { tasks.register("checkComposeCases") {
doLast { doLast {
val filterCases = project.findProperty("FILTER_CASES")?.toString() ?: "" val filterCases = project.findProperty("FILTER_CASES")?.toString() ?: ""
val composeVersion = project.findProperty("COMPOSE_CORE_VERSION")?.toString() ?: "0.0.0-SNASPHOT" val composeVersion = project.findProperty("compose.version")?.toString() ?: "0.0.0-SNASPHOT"
val kotlinVersion = kotlin.coreLibrariesVersion val kotlinVersion = kotlin.coreLibrariesVersion
val expectedFailingCasesDir = File("${projectDir.absolutePath}/testcases/failing") val expectedFailingCasesDir = File("${projectDir.absolutePath}/testcases/failing")

4
web/compose-compiler-integration/main-template/settings.gradle.kts

@ -12,8 +12,8 @@ pluginManagement {
println("KotlinVersion=[$kotlinVersion]") println("KotlinVersion=[$kotlinVersion]")
eachPlugin { eachPlugin {
if (requested.id.id == "org.jetbrains.compose") { if (requested.id.id == "org.jetbrains.compose") {
val useVersion = if (extra.has("COMPOSE_CORE_VERSION")) { val useVersion = if (extra.has("compose.version")) {
extra["COMPOSE_CORE_VERSION"].toString() extra["compose.version"].toString()
} else { } else {
"0.0.0-SNASPHOT" "0.0.0-SNASPHOT"
} }

3
web/gradle.properties

@ -1,5 +1,4 @@
COMPOSE_CORE_VERSION=1.2.0-beta02 compose.version=1.2.0-beta02
COMPOSE_WEB_VERSION=1.2.0-beta02
compose.web.buildSamples=false compose.web.buildSamples=false
compose.web.tests.integration.withFirefox compose.web.tests.integration.withFirefox
compose.web.tests.skip.benchmarks=false compose.web.tests.skip.benchmarks=false

2
web/settings.gradle.kts

@ -1,5 +1,5 @@
pluginManagement { pluginManagement {
val COMPOSE_CORE_VERSION: String by settings val COMPOSE_CORE_VERSION = extra["compose.version"] as String
println("[build] compose core version: $COMPOSE_CORE_VERSION") println("[build] compose core version: $COMPOSE_CORE_VERSION")
// pluginManagement section won't see outer scope, hence the FQ names // pluginManagement section won't see outer scope, hence the FQ names

Loading…
Cancel
Save