build.gradle.kts
122 lines · 4.8 KB
Changed in: 0.5.0
| 1 | plugins { |
| 2 | alias(libs.plugins.kotlin.multiplatform) |
| 3 | alias(libs.plugins.kotlin.serialization) |
| 4 | alias(libs.plugins.compose.multiplatform) |
| 5 | alias(libs.plugins.compose.compiler) |
| 6 | alias(libs.plugins.android.library) |
| 7 | } |
| 8 | |
| 9 | kotlin { |
| 10 | jvmToolchain(17) |
| 11 | |
| 12 | androidTarget { |
| 13 | compilations.all { |
| 14 | compilerOptions.configure { |
| 15 | jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | jvm("desktop") { |
| 21 | compilations.all { |
| 22 | compilerOptions.configure { |
| 23 | jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | // Hierarchical source sets: |
| 29 | // commonMain ── platform-agnostic domain + ViewModels + Compose theme |
| 30 | // └── jvmCommonMain ── JVM-only shared between android & desktop (jUPnP logic) |
| 31 | // ├── androidMain ── Android holder, Android-flavour Media3 renderer |
| 32 | // └── desktopMain ── DesktopUpnpServiceHolder, VlcjLocalRenderer |
| 33 | sourceSets { |
| 34 | val commonMain by getting { |
| 35 | dependencies { |
| 36 | implementation(compose.runtime) |
| 37 | implementation(compose.foundation) |
| 38 | implementation(compose.material3) |
| 39 | implementation(compose.materialIconsExtended) |
| 40 | implementation(compose.ui) |
| 41 | @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) |
| 42 | implementation(compose.components.resources) |
| 43 | |
| 44 | implementation(libs.kotlinx.coroutines.core) |
| 45 | implementation(libs.kotlinx.serialization.json) |
| 46 | |
| 47 | // Multiplatform ViewModel + viewModelScope |
| 48 | implementation(libs.androidx.lifecycle.viewmodel) |
| 49 | |
| 50 | implementation(libs.koin.core) |
| 51 | implementation(libs.koin.compose) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | val jvmCommonMain by creating { |
| 56 | dependsOn(commonMain) |
| 57 | dependencies { |
| 58 | // UPnP — jUPnP, matching upstream Android app. |
| 59 | implementation(libs.jupnp.core) |
| 60 | implementation(libs.jupnp.support) |
| 61 | implementation(libs.okhttp) |
| 62 | // RawCastClient parses Cast wire-protocol JSON payloads. Android |
| 63 | // bundles org.json; on JVM we pull it from Maven. Tiny artifact |
| 64 | // (~70KB), no transitive deps, used only inside cast/raw/. |
| 65 | implementation("org.json:json:20240303") |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | val androidMain by getting { |
| 70 | dependsOn(jvmCommonMain) |
| 71 | dependencies { |
| 72 | implementation(libs.kotlinx.coroutines.android) |
| 73 | implementation(libs.koin.android) |
| 74 | implementation(libs.androidx.activity.compose) |
| 75 | // Media3 / ExoPlayer stay in the :android app module, not :shared. |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | val desktopMain by getting { |
| 80 | dependsOn(jvmCommonMain) |
| 81 | dependencies { |
| 82 | implementation(compose.desktop.currentOs) |
| 83 | implementation(libs.kotlinx.coroutines.swing) |
| 84 | implementation(libs.vlcj) |
| 85 | implementation(libs.chromecast.api) |
| 86 | // jUPnP's default stream server is Jetty 9.x, whose deps (including the |
| 87 | // javax.servlet API) are marked provided-scope. We supply them here. |
| 88 | implementation(libs.javax.servlet.api) |
| 89 | implementation(libs.jetty.server) |
| 90 | implementation(libs.jetty.servlet) |
| 91 | implementation(libs.jetty.client) |
| 92 | // Both jUPnP and Jetty log through SLF4J. jUPnP 3.0.2 brings |
| 93 | // slf4j-api 2.x in transitively, so the binding has to match that |
| 94 | // line — 1.7.x bindings are ignored at runtime. Without a matching |
| 95 | // binding loaded, errors during stream-server startup are silently |
| 96 | // swallowed (e.g. when Jetty fails to bind we just see SSDP packets |
| 97 | // advertising a port nothing's listening on). slf4j-simple writes |
| 98 | // everything to stderr. |
| 99 | implementation(libs.slf4j.simple) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | val commonTest by getting { |
| 104 | dependencies { |
| 105 | implementation(kotlin("test")) |
| 106 | implementation(libs.kotest.assertions) |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | android { |
| 113 | namespace = "dev.stave.shared" |
| 114 | compileSdk = libs.versions.android.compileSdk.get().toInt() |
| 115 | defaultConfig { |
| 116 | minSdk = libs.versions.android.minSdk.get().toInt() |
| 117 | } |
| 118 | compileOptions { |
| 119 | sourceCompatibility = JavaVersion.VERSION_17 |
| 120 | targetCompatibility = JavaVersion.VERSION_17 |
| 121 | } |
| 122 | } |


