|
| 1 | +import org.jetbrains.compose.desktop.application.dsl.TargetFormat |
| 2 | +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi |
| 3 | +import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
| 4 | + |
| 5 | +plugins { |
| 6 | + alias(libs.plugins.kotlinMultiplatform) |
| 7 | + alias(libs.plugins.androidApplication) |
| 8 | + alias(libs.plugins.jetbrainsCompose) |
| 9 | + alias(libs.plugins.compose.compiler) |
| 10 | + alias(libs.plugins.exoquery) |
| 11 | +} |
| 12 | + |
| 13 | +// Workaround for https://youtrack.jetbrains.com/issue/KT-51970 |
| 14 | +//afterEvaluate { |
| 15 | +// afterEvaluate { |
| 16 | +// tasks.configureEach { |
| 17 | +// if ( |
| 18 | +// name.startsWith("compile") |
| 19 | +// && name.endsWith("KotlinMetadata") |
| 20 | +// ) { |
| 21 | +// println("disabling ${this}:$name") |
| 22 | +// enabled = false |
| 23 | +// } |
| 24 | +// } |
| 25 | +// } |
| 26 | +//} |
| 27 | + |
| 28 | +kotlin { |
| 29 | + androidTarget { |
| 30 | + @OptIn(ExperimentalKotlinGradlePluginApi::class) |
| 31 | + compilerOptions { |
| 32 | + jvmTarget.set(JvmTarget.JVM_17) |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + listOf( |
| 37 | + //iosX64(), |
| 38 | + iosArm64(), |
| 39 | + //iosSimulatorArm64() |
| 40 | + ).forEach { iosTarget -> |
| 41 | + iosTarget.binaries.framework { |
| 42 | + baseName = "ComposeApp" |
| 43 | + isStatic = true |
| 44 | + } |
| 45 | + iosTarget.binaries.configureEach { |
| 46 | + linkerOpts.add("-lsqlite3") |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + sourceSets { |
| 51 | + androidMain.dependencies { |
| 52 | + implementation(compose.preview) |
| 53 | + implementation(libs.androidx.activity.compose) |
| 54 | + implementation(libs.android.driver) |
| 55 | + implementation(libs.androidx.lifecycle.runtime) |
| 56 | + implementation(libs.androidx.lifecycle.runtime.ktx) |
| 57 | + implementation(libs.koin.androidx.compose) |
| 58 | + implementation(libs.exoquery.runner.android) |
| 59 | + // Android-specific dependencies |
| 60 | + implementation(libs.androidx.lifecycle.viewmodel.compose) |
| 61 | + } |
| 62 | + commonMain.dependencies { |
| 63 | + implementation(compose.runtime) |
| 64 | + implementation(compose.foundation) |
| 65 | + implementation(compose.material) |
| 66 | + implementation(compose.ui) |
| 67 | + implementation(compose.components.resources) |
| 68 | + implementation(compose.components.uiToolingPreview) |
| 69 | + implementation(projects.shared) |
| 70 | + implementation(libs.koin.compose) |
| 71 | + // Use Jetbrains Compose Material3 for multiplatform |
| 72 | + implementation(compose.material3) |
| 73 | + } |
| 74 | + iosMain.dependencies { |
| 75 | + implementation(libs.exoquery.runner.native) |
| 76 | + implementation(libs.jetbrains.annotations.kmp) |
| 77 | + } |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +configurations.all { |
| 82 | + exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-debug") |
| 83 | +} |
| 84 | + |
| 85 | +fun MinimalExternalModuleDependency.simpleString() = |
| 86 | + this.let { "${it.module}:${it.versionConstraint.requiredVersion}" } |
| 87 | + |
| 88 | +android { |
| 89 | + compileSdk = 34 // for example |
| 90 | + |
| 91 | + namespace = "com.example.project" |
| 92 | + compileSdk = libs.versions.android.compileSdk.get().toInt() |
| 93 | + |
| 94 | + sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") |
| 95 | + sourceSets["main"].res.srcDirs("src/androidMain/res") |
| 96 | + sourceSets["main"].resources.srcDirs("src/commonMain/resources") |
| 97 | + |
| 98 | + defaultConfig { |
| 99 | + minSdk = 30 |
| 100 | + applicationId = "com.example.project" |
| 101 | + minSdk = libs.versions.android.minSdk.get().toInt() |
| 102 | + targetSdk = libs.versions.android.targetSdk.get().toInt() |
| 103 | + versionCode = 1 |
| 104 | + versionName = "1.0" |
| 105 | + } |
| 106 | + packaging { |
| 107 | + resources { |
| 108 | + excludes += "/META-INF/{AL2.0,LGPL2.1}" |
| 109 | + } |
| 110 | + } |
| 111 | + buildTypes { |
| 112 | + getByName("release") { |
| 113 | + isMinifyEnabled = false |
| 114 | + } |
| 115 | + } |
| 116 | + compileOptions { |
| 117 | + sourceCompatibility = JavaVersion.VERSION_17 |
| 118 | + targetCompatibility = JavaVersion.VERSION_17 |
| 119 | + } |
| 120 | + buildFeatures { |
| 121 | + compose = true |
| 122 | + } |
| 123 | + dependencies { |
| 124 | + debugImplementation(compose.uiTooling) |
| 125 | + } |
| 126 | + // kotlinx-coroutines-debug and bytebuddy both include win32-x86-64/attach_hotspot_windows.dll, tell package to ignore |
| 127 | + packaging { |
| 128 | + resources { |
| 129 | + excludes += "**/attach_hotspot_windows.dll" |
| 130 | + } |
| 131 | + } |
| 132 | +} |
| 133 | +dependencies { |
| 134 | + implementation(libs.androidx.ui.text.google.fonts) |
| 135 | + implementation(libs.androidx.sqlite.framework) |
| 136 | +} |
| 137 | + |
| 138 | +compose.desktop { |
| 139 | + application { |
| 140 | + mainClass = "com.example.project.MainKt" |
| 141 | + |
| 142 | + nativeDistributions { |
| 143 | + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) |
| 144 | + packageName = "com.example.project" |
| 145 | + packageVersion = "1.0.0" |
| 146 | + } |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | + |
| 151 | +repositories { |
| 152 | + google { |
| 153 | + mavenContent { |
| 154 | + includeGroupAndSubgroups("androidx") |
| 155 | + includeGroupAndSubgroups("com.android") |
| 156 | + includeGroupAndSubgroups("com.google") |
| 157 | + } |
| 158 | + } |
| 159 | + mavenCentral() |
| 160 | + maven("https://s01.oss.sonatype.org/service/local/repositories/releases/content/") |
| 161 | + mavenLocal() |
| 162 | +} |
0 commit comments