|
|
@ -7,8 +7,10 @@ package org.jetbrains.compose.web |
|
|
|
|
|
|
|
|
|
|
|
import org.gradle.api.Project |
|
|
|
import org.gradle.api.Project |
|
|
|
import org.gradle.api.plugins.ExtensionAware |
|
|
|
import org.gradle.api.plugins.ExtensionAware |
|
|
|
|
|
|
|
import org.jetbrains.compose.internal.kotlinJsExtOrNull |
|
|
|
import org.jetbrains.compose.internal.mppExt |
|
|
|
import org.jetbrains.compose.internal.mppExt |
|
|
|
import org.jetbrains.compose.internal.mppExtOrNull |
|
|
|
import org.jetbrains.compose.internal.mppExtOrNull |
|
|
|
|
|
|
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget |
|
|
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget |
|
|
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget |
|
|
|
|
|
|
|
|
|
|
@ -46,16 +48,36 @@ abstract class WebExtension : ExtensionAware { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun defaultJsTargetsToConfigure(project: Project): Set<KotlinJsIrTarget> { |
|
|
|
private fun defaultJsTargetsToConfigure(project: Project): Set<KotlinJsIrTarget> { |
|
|
|
val mppTargets = project.mppExtOrNull?.targets?.asMap?.values ?: emptySet() |
|
|
|
val mppExt = project.mppExtOrNull |
|
|
|
val jsIRTargets = mppTargets.filterIsInstanceTo(LinkedHashSet<KotlinJsIrTarget>()) |
|
|
|
|
|
|
|
|
|
|
|
if (mppExt != null) { |
|
|
|
return if (jsIRTargets.size > 1) { |
|
|
|
val mppTargets = mppExt.targets.asMap.values |
|
|
|
project.logger.error( |
|
|
|
val jsIRTargets = mppTargets.filterIsInstanceTo(LinkedHashSet<KotlinJsIrTarget>()) |
|
|
|
"w: Default configuration for Compose Web is disabled: " + |
|
|
|
|
|
|
|
"multiple Kotlin JS IR targets are defined. " + |
|
|
|
return if (jsIRTargets.size > 1) { |
|
|
|
"Specify Compose Web Kotlin targets by using `compose.web.targets()`" |
|
|
|
project.logger.error( |
|
|
|
) |
|
|
|
"w: Default configuration for Compose for Web is disabled: " + |
|
|
|
emptySet() |
|
|
|
"multiple Kotlin JS IR targets are defined. " + |
|
|
|
} else jsIRTargets |
|
|
|
"Specify Compose for Web Kotlin targets by using `compose.web.targets()`" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
emptySet() |
|
|
|
|
|
|
|
} else jsIRTargets |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val jsExt = project.kotlinJsExtOrNull |
|
|
|
|
|
|
|
if (jsExt != null) { |
|
|
|
|
|
|
|
val target = jsExt.target |
|
|
|
|
|
|
|
return if (target is KotlinJsIrTarget) { |
|
|
|
|
|
|
|
setOf(target) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
project.logger.error( |
|
|
|
|
|
|
|
"w: Default configuration for Compose for Web is disabled: " + |
|
|
|
|
|
|
|
"Compose for Web does not support legacy (non-IR) JS targets" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
emptySet() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return emptySet() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |