|
|
@ -13,12 +13,11 @@ import org.gradle.api.artifacts.component.ModuleComponentIdentifier |
|
|
|
import org.gradle.api.provider.Provider |
|
|
|
import org.gradle.api.provider.Provider |
|
|
|
import org.jetbrains.compose.ComposeBuildConfig |
|
|
|
import org.jetbrains.compose.ComposeBuildConfig |
|
|
|
import org.jetbrains.compose.ComposeExtension |
|
|
|
import org.jetbrains.compose.ComposeExtension |
|
|
|
import org.jetbrains.compose.web.tasks.UnpackSkikoWasmRuntimeTask |
|
|
|
import org.jetbrains.compose.internal.utils.detachedComposeDependency |
|
|
|
import org.jetbrains.compose.internal.utils.* |
|
|
|
|
|
|
|
import org.jetbrains.compose.internal.utils.registerTask |
|
|
|
import org.jetbrains.compose.internal.utils.registerTask |
|
|
|
import org.jetbrains.compose.internal.utils.uppercaseFirstChar |
|
|
|
|
|
|
|
import org.jetbrains.compose.web.WebExtension |
|
|
|
import org.jetbrains.compose.web.WebExtension |
|
|
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget |
|
|
|
import org.jetbrains.compose.web.tasks.UnpackSkikoWasmRuntimeTask |
|
|
|
|
|
|
|
import org.jetbrains.kotlin.gradle.tasks.IncrementalSyncTask |
|
|
|
|
|
|
|
|
|
|
|
internal fun Project.configureWeb( |
|
|
|
internal fun Project.configureWeb( |
|
|
|
composeExt: ComposeExtension, |
|
|
|
composeExt: ComposeExtension, |
|
|
@ -48,11 +47,12 @@ internal fun Project.configureWeb( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// configure only if there is k/wasm or k/js target: |
|
|
|
// configure only if there is k/wasm or k/js target: |
|
|
|
webExt.targetsToConfigure(project) |
|
|
|
if (webExt.targetsToConfigure(project).isNotEmpty()) { |
|
|
|
.configureWebApplication(project, shouldRunUnpackSkiko) |
|
|
|
configureWebApplication(project, shouldRunUnpackSkiko) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
internal fun Collection<KotlinJsIrTarget>.configureWebApplication( |
|
|
|
internal fun configureWebApplication( |
|
|
|
project: Project, |
|
|
|
project: Project, |
|
|
|
shouldRunUnpackSkiko: Provider<Boolean> |
|
|
|
shouldRunUnpackSkiko: Provider<Boolean> |
|
|
|
) { |
|
|
|
) { |
|
|
@ -63,28 +63,22 @@ internal fun Collection<KotlinJsIrTarget>.configureWebApplication( |
|
|
|
skikoJsWasmRuntimeConfiguration.defaultDependencies { |
|
|
|
skikoJsWasmRuntimeConfiguration.defaultDependencies { |
|
|
|
it.addLater(skikoJsWasmRuntimeDependency) |
|
|
|
it.addLater(skikoJsWasmRuntimeDependency) |
|
|
|
} |
|
|
|
} |
|
|
|
forEach { |
|
|
|
|
|
|
|
val mainCompilation = it.compilations.getByName("main") |
|
|
|
|
|
|
|
val testCompilation = it.compilations.getByName("test") |
|
|
|
|
|
|
|
val unpackedRuntimeDir = project.layout.buildDirectory.dir("compose/skiko-wasm/${it.targetName}") |
|
|
|
|
|
|
|
val taskName = "unpackSkikoWasmRuntime${it.targetName.uppercaseFirstChar()}" |
|
|
|
|
|
|
|
mainCompilation.defaultSourceSet.resources.srcDir(unpackedRuntimeDir) |
|
|
|
|
|
|
|
testCompilation.defaultSourceSet.resources.srcDir(unpackedRuntimeDir) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val unpackRuntime = project.registerTask<UnpackSkikoWasmRuntimeTask>(taskName) { |
|
|
|
|
|
|
|
onlyIf { |
|
|
|
|
|
|
|
shouldRunUnpackSkiko.get() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
skikoRuntimeFiles = skikoJsWasmRuntimeConfiguration |
|
|
|
val unpackedRuntimeDir = project.layout.buildDirectory.dir("compose/skiko-wasm") |
|
|
|
outputDir.set(unpackedRuntimeDir) |
|
|
|
val taskName = "unpackSkikoWasmRuntime" |
|
|
|
} |
|
|
|
|
|
|
|
project.tasks.named(mainCompilation.processResourcesTaskName).configure { processResourcesTask -> |
|
|
|
val unpackRuntime = project.registerTask<UnpackSkikoWasmRuntimeTask>(taskName) { |
|
|
|
processResourcesTask.dependsOn(unpackRuntime) |
|
|
|
onlyIf { |
|
|
|
} |
|
|
|
shouldRunUnpackSkiko.get() |
|
|
|
project.tasks.named(testCompilation.processResourcesTaskName).configure { processResourcesTask -> |
|
|
|
|
|
|
|
processResourcesTask.dependsOn(unpackRuntime) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
skikoRuntimeFiles = skikoJsWasmRuntimeConfiguration |
|
|
|
|
|
|
|
outputDir.set(unpackedRuntimeDir) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
project.tasks.withType(IncrementalSyncTask::class.java) { |
|
|
|
|
|
|
|
it.dependsOn(unpackRuntime) |
|
|
|
|
|
|
|
it.from.from(unpackedRuntimeDir) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|