|
|
|
@ -7,6 +7,7 @@ import org.gradle.api.provider.Property
|
|
|
|
|
import org.gradle.api.provider.Provider |
|
|
|
|
import org.gradle.api.tasks.* |
|
|
|
|
import org.jetbrains.compose.ComposeBuildConfig |
|
|
|
|
import org.jetbrains.compose.desktop.application.internal.currentTarget |
|
|
|
|
import org.jetbrains.compose.desktop.application.internal.javaExecutable |
|
|
|
|
import org.jetbrains.compose.desktop.application.internal.notNullProperty |
|
|
|
|
import org.jetbrains.compose.desktop.tasks.AbstractComposeDesktopTask |
|
|
|
@ -52,8 +53,10 @@ abstract class AbstractConfigureDesktopPreviewTask : AbstractComposeDesktopTask(
|
|
|
|
|
hostClasspath = hostClasspath.files.asSequence().pathString() |
|
|
|
|
) |
|
|
|
|
val previewClasspathString = |
|
|
|
|
(previewClasspath.files.asSequence() + uiTooling.files.asSequence()) |
|
|
|
|
.pathString() |
|
|
|
|
(previewClasspath.files.asSequence() + |
|
|
|
|
uiTooling.files.asSequence() + |
|
|
|
|
tryGetSkikoRuntimeFilesIfNeeded().asSequence() |
|
|
|
|
).pathString() |
|
|
|
|
|
|
|
|
|
val gradleLogger = logger |
|
|
|
|
val previewLogger = GradlePreviewLoggerAdapter(gradleLogger) |
|
|
|
@ -72,6 +75,39 @@ abstract class AbstractConfigureDesktopPreviewTask : AbstractComposeDesktopTask(
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun tryGetSkikoRuntimeFilesIfNeeded(): Collection<File> { |
|
|
|
|
try { |
|
|
|
|
var hasSkikoJvm = false |
|
|
|
|
var hasSkikoJvmRuntime = false |
|
|
|
|
var skikoVersion: String? = null |
|
|
|
|
for (file in previewClasspath.files) { |
|
|
|
|
if (file.name.endsWith(".jar")) { |
|
|
|
|
if (file.name.startsWith("skiko-jvm-runtime-")) { |
|
|
|
|
hasSkikoJvmRuntime = true |
|
|
|
|
continue |
|
|
|
|
} else if (file.name.startsWith("skiko-jvm-")) { |
|
|
|
|
hasSkikoJvm = true |
|
|
|
|
skikoVersion = file.name |
|
|
|
|
.removePrefix("skiko-jvm-") |
|
|
|
|
.removeSuffix(".jar") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (hasSkikoJvmRuntime) return emptyList() |
|
|
|
|
|
|
|
|
|
if (hasSkikoJvm && skikoVersion != null && skikoVersion.isNotBlank()) { |
|
|
|
|
val skikoRuntimeConfig = project.configurations.detachedConfiguration( |
|
|
|
|
project.dependencies.create("org.jetbrains.skiko:skiko-jvm-runtime-${currentTarget.id}:$skikoVersion") |
|
|
|
|
).apply { isTransitive = false } |
|
|
|
|
return skikoRuntimeConfig.files |
|
|
|
|
} |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
// OK |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return emptyList() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun Sequence<File>.pathString(): String = |
|
|
|
|
joinToString(File.pathSeparator) { it.absolutePath } |
|
|
|
|
|
|
|
|
|