MaterialKolorBuilder/app/build.gradle.kts
Jordon de Hoog 9337330735
Feature - Export (#3)
Add exporting for web
2024-10-01 16:21:36 -04:00

221 lines
7.2 KiB
Kotlin

import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.INT
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
plugins {
alias(libs.plugins.multiplatform)
alias(libs.plugins.compose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.android.application)
alias(libs.plugins.buildKonfig)
}
buildkonfig {
packageName = libs.versions.app.name.get()
defaultConfigs {
buildConfigField(STRING, "VERSION_NAME", libs.versions.app.version.get())
buildConfigField(INT, "VERSION_CODE", libs.versions.app.code.get())
buildConfigField(STRING, "MATERIAL_KOLOR_VERSION", libs.versions.materialKolor.get())
}
}
kotlin {
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "app"
browser {
val projectDirPath = project.projectDir.path
commonWebpackConfig {
outputFileName = "app.js"
devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
static = (static ?: mutableListOf()).apply {
// Serve sources to debug inside browser
add(projectDirPath)
}
}
}
}
binaries.executable()
}
androidTarget {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
jvm("desktop")
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "App"
isStatic = true
}
}
sourceSets {
all {
languageSettings {
optIn("androidx.compose.material3.ExperimentalMaterial3Api")
optIn("androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi")
optIn("androidx.compose.foundation.layout.ExperimentalLayoutApi")
optIn("androidx.compose.foundation.ExperimentalFoundationApi")
optIn("org.jetbrains.compose.resources.ExperimentalResourceApi")
}
}
applyDefaultHierarchyTemplate()
val desktopMain by getting
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.materialIconsExtended)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.material3.adaptive)
implementation(libs.material3.adaptive.layout)
implementation(libs.material3.adaptive.navigation)
implementation(libs.material3.adaptive.navigation.suite)
implementation(libs.material3.windowSizeClass)
implementation(libs.kermit)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.datetime)
implementation(libs.kotlinx.collections)
implementation(libs.kstore)
implementation(libs.ktor.http)
implementation(libs.composeIcons.fontAwesome)
implementation(libs.stateHolder)
implementation(libs.stateHolder.compose)
implementation(libs.materialKolor)
implementation(libs.materialKolor.utilities)
implementation(libs.compose.colorpicker)
implementation(libs.calf.filePicker)
implementation(libs.androidx.lifecycle.viewmodel)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.highlights)
}
commonTest.dependencies {
implementation(kotlin("test"))
implementation(libs.kotest.assertions)
}
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.core)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.kotlinx.coroutines.guava)
implementation(libs.kstore.file)
}
iosMain.dependencies {
implementation(libs.kstore.file)
}
desktopMain.dependencies {
implementation(compose.desktop.currentOs)
implementation(libs.kotlinx.coroutines.swing)
implementation(libs.kstore.file)
}
wasmJsMain.dependencies {
implementation(libs.kstore.storage)
implementation(npm("jszip", "3.10.1"))
}
val nonBrowserMain by creating {
dependsOn(commonMain.get())
androidMain.get().dependsOn(this)
iosMain.get().dependsOn(this)
desktopMain.dependsOn(this)
}
val mobileMain by creating {
dependsOn(commonMain.get())
androidMain.get().dependsOn(this)
iosMain.get().dependsOn(this)
}
}
}
android {
namespace = libs.versions.app.name.get()
compileSdk = libs.versions.android.compileSdk.get().toInt()
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
defaultConfig {
applicationId = libs.versions.app.name.get()
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = libs.versions.app.code.get().toInt()
versionName = libs.versions.app.version.get()
}
signingConfigs {
create("release") {
storeFile = project.rootDir.resolve("keystore.key")
storePassword = System.getenv("KEYSTORE_PASSWORD")
keyAlias = System.getenv("KEYSTORE_KEY_ALIAS")
keyPassword = System.getenv("KEYSTORE_KEY_PASSWORD")
}
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
buildFeatures {
compose = true
}
dependencies {
debugImplementation(compose.uiTooling)
}
}
compose.desktop {
application {
mainClass = "${libs.versions.app.name.get()}.MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "MaterialKolorBuilder"
packageVersion = libs.versions.app.version.get()
}
}
}