-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Introduce wasmJsBrowserDistribution task #5375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
930e350
38e548f
09ecd32
0ad0d7c
7afaf52
7126308
88e7d98
b89fc65
0d3f551
443ec35
f3b3036
616cf52
2ce4a31
8bcf5a8
b3f48dc
30ecac2
41e6aa2
d90b3d0
7cb2ded
e133bb2
14bef86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Co-authored-by: Oleksandr Karpovich <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package org.jetbrains.compose.web.tasks | |
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.Project | ||
import org.gradle.api.file.ConfigurableFileCollection | ||
import org.gradle.api.file.DirectoryProperty | ||
import org.gradle.api.file.DuplicatesStrategy | ||
import org.gradle.api.file.FileCollection | ||
|
@@ -19,6 +20,7 @@ import org.jetbrains.compose.internal.utils.registerTask | |
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget | ||
import javax.inject.Inject | ||
import kotlin.math.log | ||
|
||
abstract class WebCompatibilityTask : DefaultTask() { | ||
@get:Inject | ||
|
@@ -28,10 +30,10 @@ abstract class WebCompatibilityTask : DefaultTask() { | |
abstract val outputDir: DirectoryProperty | ||
|
||
@get:InputFiles | ||
lateinit var jsDistFiles: FileCollection | ||
abstract val jsDistFiles: ConfigurableFileCollection | ||
|
||
@get:InputFiles | ||
lateinit var wasmDistFiles: FileCollection | ||
abstract val wasmDistFiles: ConfigurableFileCollection | ||
|
||
@get:Input | ||
@get:Optional | ||
|
@@ -126,23 +128,36 @@ abstract class WebCompatibilityTask : DefaultTask() { | |
|
||
private fun Project.registerWebCompatibilityTask(mppPlugin: KotlinMultiplatformExtension) = registerTask<WebCompatibilityTask>("composeWebCompatibilityDist") { | ||
eymar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
val webProductionDist = layout.buildDirectory.dir("dist/web/productionExecutable") | ||
terrakok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
outputDir.set(webProductionDist) | ||
|
||
mppPlugin.targets.matching { it is KotlinJsIrTarget }.all { target -> | ||
val outputName = when { | ||
(target as KotlinJsIrTarget).wasmTargetType == null -> wasmOutputName | ||
(target as KotlinJsIrTarget).wasmTargetType != null -> wasmOutputName | ||
else -> jsOutputName | ||
} | ||
|
||
outputName.set(target.outputModuleName) | ||
terrakok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
|
||
onlyIf { | ||
jsOutputName.orNull != null && wasmOutputName.orNull != null | ||
val hasBothDistributions = !jsDistFiles.isEmpty && !wasmDistFiles.isEmpty | ||
val hasBothOutputs = jsOutputName.orNull != null && wasmOutputName.orNull != null | ||
|
||
if (!hasBothDistributions) { | ||
logger.lifecycle("Task ${this.name} skipped: no js and wasm distributions found, both are required for compatibility") | ||
} else if (!hasBothOutputs) { | ||
logger.lifecycle("Task ${this.name} skipped: no js and wasm output names specified") | ||
|
||
} | ||
hasBothDistributions && hasBothOutputs | ||
} | ||
|
||
outputDir.set(webProductionDist) | ||
jsDistFiles = tasks.named("jsBrowserDistribution").get().outputs.files | ||
wasmDistFiles = tasks.named("wasmJsBrowserDistribution").get().outputs.files | ||
jsDistFiles.from(project.provider { | ||
project.tasks.findByName("jsBrowserDistribution")?.outputs?.files ?: project.files() | ||
}) | ||
|
||
wasmDistFiles.from(project.provider { | ||
project.tasks.findByName("wasmJsBrowserDistribution")?.outputs?.files ?: project.files() | ||
}) | ||
} | ||
|
||
internal fun Project.configureWebCompatibility() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add a description what's going here |
||
|
Uh oh!
There was an error while loading. Please reload this page.