Skip to content
Open
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
8 changes: 6 additions & 2 deletions ci/compose-uber-jar/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ val composeVersion: String by lazy {
}

dependencies {
implementation("org.jetbrains.compose.desktop:desktop-jvm-macos-x64:$composeVersion")
implementation("org.jetbrains.compose.desktop:desktop-jvm-linux-x64:$composeVersion")
implementation("org.jetbrains.compose.desktop:desktop-jvm-macos-x64:$composeVersion") {
exclude("org.jetbrains.skiko", "skiko-awt-runtime")
}
implementation("org.jetbrains.compose.desktop:desktop-jvm-linux-x64:$composeVersion") {
exclude("org.jetbrains.skiko", "skiko-awt-runtime")
}
}

val shadowJar = tasks.named("shadowJar", ShadowJar::class) {
Expand Down
5 changes: 4 additions & 1 deletion components/resources/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ kotlin {
dependsOn(skikoTest)
dependsOn(jvmAndAndroidTest)
dependencies {
implementation(compose.desktop.currentOs)
implementation(libs.compose.desktop)
}
}
val androidMain by getting {
Expand All @@ -135,6 +135,9 @@ kotlin {
}
val androidUnitTest by getting {
dependsOn(jvmAndAndroidTest)
dependencies {
implementation(libs.compose.desktop)
}
}
val nativeMain by getting {
dependsOn(skikoMain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import org.gradle.api.provider.ProviderFactory
import org.jetbrains.compose.internal.utils.findLocalOrGlobalProperty
import org.jetbrains.compose.internal.utils.toBooleanProvider
import org.jetbrains.compose.internal.utils.valueOrNull
import org.jetbrains.kotlin.gradle.plugin.extraProperties

internal object ComposeProperties {
internal const val VERBOSE = "compose.desktop.verbose"
Expand All @@ -29,6 +28,7 @@ internal object ComposeProperties {
internal const val DISABLE_HOT_RELOAD = "org.jetbrains.compose.hot.reload.disable"
internal const val DISABLE_RESOURCE_CONTENT_HASH_GENERATION = "org.jetbrains.compose.resources.content.hash.generation.disable"
internal const val DISABLE_LIBRARY_COMPATIBILITY_CHECK = "org.jetbrains.compose.library.compatibility.check.disable"
internal const val DISABLE_SKIKO_AWT_RUNTIME_CONSTRAINTS = "org.jetbrains.compose.skiko.awt.runtime.constraints.disable"

fun isVerbose(providers: ProviderFactory): Provider<Boolean> =
providers.valueOrNull(VERBOSE).toBooleanProvider(false)
Expand Down Expand Up @@ -72,6 +72,9 @@ internal object ComposeProperties {
fun disableLibraryCompatibilityCheck(providers: ProviderFactory): Provider<Boolean> =
providers.valueOrNull(DISABLE_LIBRARY_COMPATIBILITY_CHECK).toBooleanProvider(false)

fun disableSkikoAwtRuntimeConstraints(providers: ProviderFactory): Provider<Boolean> =
providers.valueOrNull(DISABLE_SKIKO_AWT_RUNTIME_CONSTRAINTS).toBooleanProvider(false)

//providers.valueOrNull works only with root gradle.properties
fun dontSyncResources(project: Project): Provider<Boolean> =
project.findLocalOrGlobalProperty(SYNC_RESOURCES_PROPERTY).map { it == "false" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.jetbrains.compose.desktop.application.internal

import org.gradle.api.Project
import org.jetbrains.compose.desktop.DesktopExtension
import org.jetbrains.compose.desktop.internal.configureDesktopPlatformDependencies
import org.jetbrains.compose.desktop.tasks.AbstractUnpackDefaultComposeApplicationResourcesTask
import org.jetbrains.compose.internal.utils.registerTask

Expand All @@ -26,4 +27,5 @@ internal fun configureDesktop(project: Project, desktopExtension: DesktopExtensi
}

project.configureHotReload()
project.configureDesktopPlatformDependencies()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.jetbrains.compose.desktop.internal

import org.gradle.api.Project
import org.gradle.nativeplatform.MachineArchitecture
import org.gradle.nativeplatform.OperatingSystemFamily
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.compose.desktop.application.internal.ComposeProperties

internal fun Project.configureDesktopPlatformDependencies() {
if (!ComposeProperties.disableSkikoAwtRuntimeConstraints(providers).get()) {
val currentOs = DefaultNativePlatform.getCurrentOperatingSystem()
val currentArch = DefaultNativePlatform.getCurrentArchitecture()

val os = objects.named(
OperatingSystemFamily::class.java, when {
currentOs.isMacOsX -> OperatingSystemFamily.MACOS
currentOs.isLinux -> OperatingSystemFamily.LINUX
currentOs.isWindows -> OperatingSystemFamily.WINDOWS
else -> "unknown"
}
)

@Suppress("UnstableApiUsage") val arch = objects.named(
MachineArchitecture::class.java, when {
currentArch.isArm64 -> MachineArchitecture.ARM64
currentArch.isAmd64 -> MachineArchitecture.X86_64
else -> "unknown"
}
)

project.configurations.all { configuration ->
if (!configuration.isCanBeConsumed || configuration.isCanBeResolved) {
try {
configuration.dependencyConstraints.add(project.dependencies.constraints.create("org.jetbrains.skiko:skiko-awt-runtime") {
it.attributes { attrs ->
attrs.attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, os)
attrs.attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, arch)
}
})
} catch (_: Throwable) {
project.logger.debug("Skipping os/arch constraint for config ${configuration.name}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this error not expected? Then it is better to print the stacktrace.

}
}
}
}
}
Loading