141 lines
3.6 KiB
Kotlin
141 lines
3.6 KiB
Kotlin
import org.jetbrains.compose.desktop.application.dsl.TargetFormat.Deb
|
|
import org.jetbrains.compose.desktop.application.dsl.TargetFormat.Dmg
|
|
import org.jetbrains.compose.desktop.application.dsl.TargetFormat.Msi
|
|
import org.jetbrains.compose.desktop.application.tasks.AbstractNativeMacApplicationPackageTask
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
|
|
|
|
plugins {
|
|
kotlin("multiplatform")
|
|
id("com.android.application")
|
|
id("org.jetbrains.compose")
|
|
}
|
|
|
|
kotlin {
|
|
@OptIn(ExperimentalWasmDsl::class)
|
|
wasmJs {
|
|
moduleName = "composeApp"
|
|
browser {
|
|
commonWebpackConfig {
|
|
outputFileName = "composeApp.js"
|
|
}
|
|
}
|
|
binaries.executable()
|
|
}
|
|
}
|
|
|
|
setupModuleForComposeMultiplatform(
|
|
fullyMultiplatform = true,
|
|
withKotlinExplicitMode = false
|
|
)
|
|
|
|
android {
|
|
namespace = "cafe.adriel.voyager.sample.multiplatform"
|
|
}
|
|
|
|
kotlin {
|
|
val macOsConfiguation: KotlinNativeTarget.() -> Unit = {
|
|
binaries {
|
|
executable {
|
|
entryPoint = "main"
|
|
freeCompilerArgs += listOf(
|
|
"-linker-option",
|
|
"-framework",
|
|
"-linker-option",
|
|
"Metal"
|
|
)
|
|
}
|
|
}
|
|
}
|
|
macosX64(macOsConfiguation)
|
|
macosArm64(macOsConfiguation)
|
|
listOf(
|
|
iosX64(),
|
|
iosArm64(),
|
|
iosSimulatorArm64()
|
|
).forEach { iosTarget ->
|
|
iosTarget.binaries.framework {
|
|
baseName = "ComposeApp"
|
|
isStatic = true
|
|
}
|
|
}
|
|
|
|
js(IR) {
|
|
browser()
|
|
binaries.executable()
|
|
}
|
|
|
|
sourceSets {
|
|
commonMain.dependencies {
|
|
implementation(compose.material)
|
|
implementation(compose.runtime)
|
|
|
|
implementation(projects.voyagerCore)
|
|
implementation(projects.voyagerNavigator)
|
|
implementation(libs.coroutines.core)
|
|
}
|
|
|
|
androidMain.dependencies {
|
|
implementation(libs.appCompat)
|
|
implementation(libs.compose.activity)
|
|
}
|
|
|
|
val desktopMain by getting {
|
|
dependencies {
|
|
implementation(compose.desktop.currentOs)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
android {
|
|
defaultConfig {
|
|
applicationId = "cafe.adriel.voyager.sample.multiplatform"
|
|
}
|
|
}
|
|
|
|
compose.desktop {
|
|
application {
|
|
mainClass = "cafe.adriel.voyager.sample.multiplatform.AppKt"
|
|
nativeDistributions {
|
|
targetFormats(Dmg, Msi, Deb)
|
|
packageName = "jvm"
|
|
packageVersion = "1.0.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
compose.desktop.nativeApplication {
|
|
targets(kotlin.targets.getByName("macosX64"))
|
|
distributions {
|
|
targetFormats(Dmg)
|
|
packageName = "MultiplatformSample"
|
|
packageVersion = "1.0.0"
|
|
}
|
|
}
|
|
|
|
afterEvaluate {
|
|
val baseTask = "createDistributableNative"
|
|
listOf("debug", "release").forEach {
|
|
val createAppTaskName = baseTask + it.capitalize() + "macosX64".capitalize()
|
|
|
|
val createAppTask = tasks.findByName(createAppTaskName) as? AbstractNativeMacApplicationPackageTask?
|
|
?: return@forEach
|
|
|
|
val destinationDir = createAppTask.destinationDir.get().asFile
|
|
val packageName = createAppTask.packageName.get()
|
|
|
|
tasks.create("runNative" + it.capitalize()) {
|
|
group = createAppTask.group
|
|
dependsOn(createAppTaskName)
|
|
doLast {
|
|
ProcessBuilder("open", destinationDir.absolutePath + "/" + packageName + ".app").start().waitFor()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
compose.experimental {
|
|
web.application {}
|
|
}
|