mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-23 09:42:07 +00:00
332 lines
12 KiB
Text
332 lines
12 KiB
Text
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
|
import org.gradle.api.DefaultTask
|
|
import org.gradle.api.file.DirectoryProperty
|
|
import org.gradle.api.file.RegularFileProperty
|
|
import org.gradle.api.provider.Property
|
|
import org.gradle.api.tasks.Input
|
|
import org.gradle.api.tasks.InputFile
|
|
import org.gradle.api.tasks.Optional
|
|
import org.gradle.api.tasks.OutputDirectory
|
|
import org.gradle.api.tasks.TaskAction
|
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
|
import java.util.Properties
|
|
|
|
abstract class GenerateRuntimeConfigsTask : DefaultTask() {
|
|
@get:OutputDirectory
|
|
abstract val outputDir: DirectoryProperty
|
|
|
|
@get:Optional
|
|
@get:InputFile
|
|
abstract val localPropertiesFile: RegularFileProperty
|
|
|
|
@get:Input
|
|
abstract val appVersionName: Property<String>
|
|
|
|
@get:Input
|
|
abstract val appVersionCode: Property<Int>
|
|
|
|
@TaskAction
|
|
fun generate() {
|
|
val props = Properties()
|
|
localPropertiesFile.asFile.orNull?.takeIf { it.exists() }?.inputStream()?.use { props.load(it) }
|
|
|
|
val outDir = outputDir.get().asFile
|
|
outDir.resolve("com/nuvio/app/core/network").apply {
|
|
mkdirs()
|
|
resolve("SupabaseConfig.kt").writeText(
|
|
"""
|
|
|package com.nuvio.app.core.network
|
|
|
|
|
|object SupabaseConfig {
|
|
| const val URL = "${props.getProperty("SUPABASE_URL", "")}"
|
|
| const val ANON_KEY = "${props.getProperty("SUPABASE_ANON_KEY", "")}"
|
|
|}
|
|
""".trimMargin()
|
|
)
|
|
}
|
|
|
|
outDir.resolve("com/nuvio/app/features/tmdb/TmdbConfig.kt").delete()
|
|
|
|
outDir.resolve("com/nuvio/app/features/trakt").apply {
|
|
mkdirs()
|
|
resolve("TraktConfig.kt").writeText(
|
|
"""
|
|
|package com.nuvio.app.features.trakt
|
|
|
|
|
|object TraktConfig {
|
|
| const val CLIENT_ID = "${props.getProperty("TRAKT_CLIENT_ID", "")}"
|
|
| const val CLIENT_SECRET = "${props.getProperty("TRAKT_CLIENT_SECRET", "")}"
|
|
| const val REDIRECT_URI = "${props.getProperty("TRAKT_REDIRECT_URI", "nuvio://auth/trakt")}"
|
|
|}
|
|
""".trimMargin()
|
|
)
|
|
}
|
|
|
|
outDir.resolve("com/nuvio/app/features/player/skip").apply {
|
|
mkdirs()
|
|
resolve("IntroDbConfig.kt").writeText(
|
|
"""
|
|
|package com.nuvio.app.features.player.skip
|
|
|
|
|
|object IntroDbConfig {
|
|
| const val URL = "${props.getProperty("INTRODB_API_URL", "")}"
|
|
|}
|
|
""".trimMargin()
|
|
)
|
|
}
|
|
|
|
outDir.resolve("com/nuvio/app/core/build").apply {
|
|
mkdirs()
|
|
resolve("AppVersionConfig.kt").writeText(
|
|
"""
|
|
|package com.nuvio.app.core.build
|
|
|
|
|
|object AppVersionConfig {
|
|
| const val VERSION_NAME = "${appVersionName.get()}"
|
|
| const val VERSION_CODE = ${appVersionCode.get()}
|
|
|}
|
|
""".trimMargin()
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
fun readXcconfigValue(file: File, key: String): String? {
|
|
if (!file.exists()) return null
|
|
return file.readLines()
|
|
.asSequence()
|
|
.map(String::trim)
|
|
.filter { it.isNotEmpty() && !it.startsWith("#") && it.contains('=') }
|
|
.map { line ->
|
|
val separatorIndex = line.indexOf('=')
|
|
line.substring(0, separatorIndex).trim() to line.substring(separatorIndex + 1).trim()
|
|
}
|
|
.firstOrNull { (entryKey, _) -> entryKey == key }
|
|
?.second
|
|
}
|
|
|
|
plugins {
|
|
alias(libs.plugins.kotlinMultiplatform)
|
|
alias(libs.plugins.androidApplication)
|
|
alias(libs.plugins.composeMultiplatform)
|
|
alias(libs.plugins.composeCompiler)
|
|
alias(libs.plugins.kotlinxSerialization)
|
|
}
|
|
|
|
val supabaseProps = Properties().apply {
|
|
val propsFile = rootProject.file("local.properties")
|
|
if (propsFile.exists()) propsFile.inputStream().use { load(it) }
|
|
}
|
|
val releaseStoreFile = supabaseProps.getProperty("NUVIO_RELEASE_STORE_FILE")?.takeIf { it.isNotBlank() }
|
|
val releaseStorePassword = supabaseProps.getProperty("NUVIO_RELEASE_STORE_PASSWORD")?.takeIf { it.isNotBlank() }
|
|
val releaseKeyAlias = supabaseProps.getProperty("NUVIO_RELEASE_KEY_ALIAS")?.takeIf { it.isNotBlank() }
|
|
val releaseKeyPassword = supabaseProps.getProperty("NUVIO_RELEASE_KEY_PASSWORD")?.takeIf { it.isNotBlank() }
|
|
val releaseKeystore = releaseStoreFile?.let(rootProject::file)
|
|
val appVersionConfigFile = rootProject.file("iosApp/Configuration/Version.xcconfig")
|
|
val releaseAppVersionName = readXcconfigValue(appVersionConfigFile, "MARKETING_VERSION")
|
|
?: error("MARKETING_VERSION is missing from ${appVersionConfigFile.path}")
|
|
val releaseAppVersionCode = readXcconfigValue(appVersionConfigFile, "CURRENT_PROJECT_VERSION")
|
|
?.toIntOrNull()
|
|
?: error("CURRENT_PROJECT_VERSION is missing or invalid in ${appVersionConfigFile.path}")
|
|
val iosDistribution = (
|
|
providers.gradleProperty("nuvio.ios.distribution").orNull
|
|
?: System.getenv("NUVIO_IOS_DISTRIBUTION")
|
|
?: supabaseProps.getProperty("NUVIO_IOS_DISTRIBUTION")
|
|
?: "appstore"
|
|
).trim().lowercase()
|
|
require(iosDistribution == "appstore" || iosDistribution == "full") {
|
|
"NUVIO_IOS_DISTRIBUTION must be 'appstore' or 'full'."
|
|
}
|
|
val iosDistributionSourceDir = if (iosDistribution == "full") {
|
|
"src/iosFull/kotlin"
|
|
} else {
|
|
"src/iosAppStore/kotlin"
|
|
}
|
|
val fullCommonSourceDir = project.file("src/fullCommonMain/kotlin")
|
|
val generatedRuntimeConfigDir = layout.buildDirectory.dir("generated/runtime-config/kotlin")
|
|
|
|
val generateRuntimeConfigs = tasks.register<GenerateRuntimeConfigsTask>("generateRuntimeConfigs") {
|
|
outputDir.set(generatedRuntimeConfigDir)
|
|
localPropertiesFile.set(rootProject.layout.projectDirectory.file("local.properties"))
|
|
appVersionName.set(releaseAppVersionName)
|
|
appVersionCode.set(releaseAppVersionCode)
|
|
}
|
|
|
|
tasks.withType<KotlinCompilationTask<*>>().configureEach {
|
|
dependsOn(generateRuntimeConfigs)
|
|
}
|
|
|
|
kotlin {
|
|
androidTarget {
|
|
compilerOptions {
|
|
jvmTarget.set(JvmTarget.JVM_11)
|
|
}
|
|
}
|
|
|
|
val iosTargets = listOf(
|
|
iosArm64(),
|
|
iosSimulatorArm64()
|
|
)
|
|
|
|
iosTargets.forEach { iosTarget ->
|
|
iosTarget.compilations.getByName("main") {
|
|
cinterops {
|
|
create("commoncrypto") {
|
|
defFile(project.file("src/nativeInterop/cinterop/commoncrypto.def"))
|
|
compilerOpts("-I${project.projectDir}/src/nativeInterop/cinterop")
|
|
}
|
|
}
|
|
|
|
if (iosDistribution == "full") {
|
|
defaultSourceSet.kotlin.srcDir(fullCommonSourceDir)
|
|
}
|
|
defaultSourceSet.kotlin.srcDir(project.file(iosDistributionSourceDir))
|
|
defaultSourceSet.dependencies {
|
|
implementation(libs.ktor.client.darwin)
|
|
if (iosDistribution == "full") {
|
|
implementation(libs.quickjs.kt)
|
|
implementation(libs.ksoup)
|
|
}
|
|
}
|
|
}
|
|
|
|
iosTarget.binaries.framework {
|
|
baseName = "ComposeApp"
|
|
isStatic = true
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
val commonMain by getting {
|
|
kotlin.srcDir(generatedRuntimeConfigDir)
|
|
}
|
|
androidMain.dependencies {
|
|
implementation(libs.compose.uiToolingPreview)
|
|
implementation(libs.androidx.activity.compose)
|
|
implementation(libs.androidx.core.splashscreen)
|
|
implementation(libs.androidx.work.runtime)
|
|
implementation(libs.coil.gif)
|
|
implementation("androidx.recyclerview:recyclerview:1.4.0")
|
|
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
|
implementation("com.google.code.gson:gson:2.11.0")
|
|
implementation("io.github.peerless2012:ass-media:0.4.0-beta01")
|
|
implementation(libs.ktor.client.android)
|
|
implementation(libs.androidx.media3.exoplayer.hls)
|
|
implementation(libs.androidx.media3.exoplayer.dash)
|
|
implementation(libs.androidx.media3.exoplayer.smoothstreaming)
|
|
implementation(libs.androidx.media3.exoplayer.rtsp)
|
|
implementation(libs.androidx.media3.datasource)
|
|
implementation(libs.androidx.media3.datasource.okhttp)
|
|
implementation(libs.androidx.media3.decoder)
|
|
implementation(libs.androidx.media3.session)
|
|
implementation(libs.androidx.media3.common)
|
|
implementation(libs.androidx.media3.container)
|
|
implementation(libs.androidx.media3.extractor)
|
|
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("lib-*.aar"))))
|
|
}
|
|
commonMain.dependencies {
|
|
implementation(libs.coil.compose)
|
|
implementation(libs.coil.network.ktor3)
|
|
implementation("dev.chrisbanes.haze:haze:1.7.2")
|
|
implementation(libs.compose.runtime)
|
|
implementation(libs.compose.foundation)
|
|
implementation(libs.compose.material3)
|
|
implementation(compose.materialIconsExtended)
|
|
implementation(libs.compose.ui)
|
|
implementation(libs.compose.components.resources)
|
|
implementation(libs.compose.uiToolingPreview)
|
|
implementation(libs.androidx.lifecycle.viewmodelCompose)
|
|
implementation(libs.androidx.lifecycle.runtimeCompose)
|
|
implementation(libs.kotlinx.serialization.json)
|
|
implementation(libs.androidx.navigation.compose)
|
|
implementation(libs.kermit)
|
|
implementation(libs.supabase.postgrest)
|
|
implementation(libs.supabase.auth)
|
|
implementation(libs.supabase.functions)
|
|
implementation(libs.reorderable)
|
|
}
|
|
commonTest.dependencies {
|
|
implementation(libs.kotlin.test)
|
|
}
|
|
}
|
|
}
|
|
|
|
afterEvaluate {
|
|
dependencies {
|
|
add("fullImplementation", libs.quickjs.kt)
|
|
add("fullImplementation", libs.ksoup)
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
debugImplementation(libs.compose.uiTooling)
|
|
}
|
|
|
|
configurations.all {
|
|
exclude(group = "androidx.media3", module = "media3-exoplayer")
|
|
exclude(group = "androidx.media3", module = "media3-ui")
|
|
}
|
|
|
|
android {
|
|
namespace = "com.nuvio.app"
|
|
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
|
|
|
signingConfigs {
|
|
create("release") {
|
|
if (releaseKeystore != null && releaseStorePassword != null && releaseKeyAlias != null && releaseKeyPassword != null) {
|
|
storeFile = releaseKeystore
|
|
storePassword = releaseStorePassword
|
|
keyAlias = releaseKeyAlias
|
|
keyPassword = releaseKeyPassword
|
|
}
|
|
}
|
|
}
|
|
|
|
defaultConfig {
|
|
applicationId = "com.nuvio.app"
|
|
minSdk = libs.versions.android.minSdk.get().toInt()
|
|
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
|
versionCode = releaseAppVersionCode
|
|
versionName = releaseAppVersionName
|
|
}
|
|
flavorDimensions += "distribution"
|
|
productFlavors {
|
|
create("full") {
|
|
dimension = "distribution"
|
|
}
|
|
create("playstore") {
|
|
dimension = "distribution"
|
|
}
|
|
}
|
|
sourceSets.getByName("full") {
|
|
java.srcDir(fullCommonSourceDir)
|
|
}
|
|
packaging {
|
|
resources {
|
|
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
|
}
|
|
jniLibs {
|
|
pickFirsts += listOf(
|
|
"lib/*/libc++_shared.so",
|
|
"lib/*/libavcodec.so",
|
|
"lib/*/libavutil.so",
|
|
"lib/*/libswscale.so",
|
|
"lib/*/libswresample.so"
|
|
)
|
|
}
|
|
}
|
|
buildTypes {
|
|
getByName("release") {
|
|
isMinifyEnabled = false
|
|
signingConfig = signingConfigs.getByName("release")
|
|
ndk {
|
|
debugSymbolLevel = "FULL"
|
|
}
|
|
}
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_11
|
|
targetCompatibility = JavaVersion.VERSION_11
|
|
}
|
|
}
|