Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal fun Project.checkComposeCompilerPlugin() {
}
}

internal const val minimalSupportedKgpVersion = "2.1.0"
internal const val minimalSupportedKgpVersion = "2.2.0"
internal const val minimalSupportedKgpVersionError = "e: Configuration problem: " +
"Minimal supported Kotlin Gradle Plugin version is $minimalSupportedKgpVersion"
internal const val newComposeCompilerKotlinSupportPluginId = "org.jetbrains.kotlin.plugin.compose"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,7 @@ import org.jetbrains.compose.internal.mppExt
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget

private const val minimalKotlinVersionForCHR = "2.1.20"

private const val minimalKotlinVersionForCHRWarning = "w: " +
"Compose Hot Reload is disabled. To make use of it, you need to be on Kotlin $minimalKotlinVersionForCHR or higher."

private fun Project.applyHotReload(kgp: KotlinBasePlugin) {
// check minimal kotlin version requirement
val kgpVersion = kgp.pluginVersion
if (Version.fromString(kgpVersion) < Version.fromString(minimalKotlinVersionForCHR)) {
logger.warn(minimalKotlinVersionForCHRWarning)
return
}

// We add an explicit runtime dependency to the Compose Hot Reload Gradle plugin of a
// specific preferred version (https://docs.gradle.org/current/userguide/dependency_versions.html),
// so we are able to apply the plugin by id here at least of that preferred version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private fun Project.onKgpApplied(config: Provider<ResourcesExtension>, kgp: Kotl

if (kmpResourcesAreAvailable) {
configureMultimoduleResources(kotlinExtension, config)
configureXCFrameworkComposeResources(kotlinExtension, kgp)
configureXCFrameworkComposeResources(kotlinExtension)
} else {
if (!disableMultimoduleResources) {
if (!hasKmpResources) logger.info(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,30 @@
package org.jetbrains.compose.resources

import org.gradle.api.Project
import org.jetbrains.compose.internal.Version
import org.jetbrains.kotlin.gradle.ComposeKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin
import org.jetbrains.kotlin.gradle.plugin.extraProperties
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFrameworkTask
import org.jetbrains.kotlin.gradle.plugin.mpp.resources.KotlinTargetResourcesPublication

private const val MIN_KGP_VERSION_FOR_XCFRAMEWORK_RESOURCES = "2.2.0-Beta2-1"

@OptIn(ComposeKotlinGradlePluginApi::class)
internal fun Project.configureXCFrameworkComposeResources(
kotlinExtension: KotlinMultiplatformExtension,
kgp: KotlinBasePlugin
kotlinExtension: KotlinMultiplatformExtension
) {
val kgpVersion = Version.fromString(kgp.pluginVersion)
val kmpResources = extraProperties.get(KMP_RES_EXT) as KotlinTargetResourcesPublication
val requiredVersion = Version.fromString(MIN_KGP_VERSION_FOR_XCFRAMEWORK_RESOURCES)
val isAvailable = kgpVersion >= requiredVersion

tasks.withType(XCFrameworkTask::class.java).configureEach { task ->
if (isAvailable) {
logger.info("Configure compose resources in ${task.name}")
kotlinExtension.targets
.withType(KotlinNativeTarget::class.java)
.configureEach { target ->
target.binaries.withType(Framework::class.java).configureEach { framework ->
task.addTargetResources(
resources = kmpResources.resolveResources(target),
target = framework.target.konanTarget
)
}
logger.info("Configure compose resources in ${task.name}")
kotlinExtension.targets
.withType(KotlinNativeTarget::class.java)
.configureEach { target ->
target.binaries.withType(Framework::class.java).configureEach { framework ->
task.addTargetResources(
resources = kmpResources.resolveResources(target),
target = framework.target.konanTarget
)
}
} else {
logger.warn("Compose resources are supported in XCFrameworks " +
"since '$MIN_KGP_VERSION_FOR_XCFRAMEWORK_RESOURCES' Kotlin Gradle plugin version")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class HotReloadTest : GradlePluginTestBase() {
TestEnvironment(defaultTestEnvironment.workingDir, kotlinVersion = "2.1.0")))
{
gradleFailure("hotRun").checks {
check.logContains("w: Compose Hot Reload is disabled")
check.logContains("Task 'hotRun' not found")
check.logContains("e: Configuration problem: Minimal supported Kotlin")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,8 @@ class ResourcesTest : GradlePluginTestBase() {
|
""".trimMargin()
}
gradle(":assembleComposeAppDebugXCFramework", "--dry-run").checks {
check.logContains("Compose resources are supported in XCFrameworks since '2.2.0-Beta2-1' Kotlin Gradle plugin version")
gradleFailure(":assembleComposeAppDebugXCFramework", "--dry-run").checks {
check.logContains("e: Configuration problem: Minimal supported Kotlin")
}
}
}
Expand Down
Loading