mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
Allow preview to work without explicit dependency on compose.uiTooling (#972)
Add runtime-only module org.jetbrains.compose.ui:ui-tooling-desktop to preview classpath in configureDesktopPreview task
This commit is contained in:
@@ -35,6 +35,11 @@ abstract class AbstractConfigureDesktopPreviewTask : AbstractComposeDesktopTask(
|
||||
internal val idePort: Provider<String> =
|
||||
project.providers.gradleProperty("compose.desktop.preview.ide.port")
|
||||
|
||||
@get:InputFiles
|
||||
internal val uiTooling = project.configurations.detachedConfiguration(
|
||||
project.dependencies.create("org.jetbrains.compose.ui:ui-tooling-desktop:${ComposeBuildConfig.composeVersion}")
|
||||
).apply { isTransitive = false }
|
||||
|
||||
@get:InputFiles
|
||||
internal val hostClasspath = project.configurations.detachedConfiguration(
|
||||
project.dependencies.create("org.jetbrains.compose:preview-rpc:${ComposeBuildConfig.composeVersion}")
|
||||
@@ -44,9 +49,11 @@ abstract class AbstractConfigureDesktopPreviewTask : AbstractComposeDesktopTask(
|
||||
fun run() {
|
||||
val hostConfig = PreviewHostConfig(
|
||||
javaExecutable = javaExecutable(javaHome.get()),
|
||||
hostClasspath = hostClasspath.files.pathString()
|
||||
hostClasspath = hostClasspath.files.asSequence().pathString()
|
||||
)
|
||||
val previewClasspathString = previewClasspath.files.pathString()
|
||||
val previewClasspathString =
|
||||
(previewClasspath.files.asSequence() + uiTooling.files.asSequence())
|
||||
.pathString()
|
||||
|
||||
val gradleLogger = logger
|
||||
val previewLogger = GradlePreviewLoggerAdapter(gradleLogger)
|
||||
@@ -65,7 +72,7 @@ abstract class AbstractConfigureDesktopPreviewTask : AbstractComposeDesktopTask(
|
||||
}
|
||||
}
|
||||
|
||||
private fun Collection<File>.pathString(): String =
|
||||
private fun Sequence<File>.pathString(): String =
|
||||
joinToString(File.pathSeparator) { it.absolutePath }
|
||||
|
||||
private class GradlePreviewLoggerAdapter(
|
||||
|
||||
@@ -14,7 +14,6 @@ kotlin {
|
||||
api(compose.runtime)
|
||||
api(compose.foundation)
|
||||
api(compose.material)
|
||||
api(compose.uiTooling)
|
||||
}
|
||||
}
|
||||
named("desktopMain") {
|
||||
|
||||
@@ -7,6 +7,4 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
implementation(compose.desktop.currentOs)
|
||||
// todo: remove after update
|
||||
implementation(compose.uiTooling)
|
||||
}
|
||||
Reference in New Issue
Block a user