You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
176 lines
6.0 KiB
Kotlin
176 lines
6.0 KiB
Kotlin
plugins {
|
|
id("com.android.application")
|
|
id("org.jetbrains.kotlin.android")
|
|
id("org.jetbrains.kotlin.plugin.serialization")
|
|
id("com.google.devtools.ksp")
|
|
}
|
|
|
|
val localDebugCaCertSource = rootDir.resolve("../deploy/certs/android-local/local_ca.crt")
|
|
val generatedLocalDebugTrustDir = layout.buildDirectory.dir("generated/localDebugTrust")
|
|
val generatedLocalDebugTrustRoot = generatedLocalDebugTrustDir.get().asFile
|
|
val generatedLocalDebugResDir = generatedLocalDebugTrustRoot.resolve("res")
|
|
val generatedLocalDebugManifestFile = generatedLocalDebugTrustRoot.resolve("AndroidManifest.xml")
|
|
|
|
android {
|
|
namespace = "com.onlinemsg.client"
|
|
compileSdk = 34
|
|
|
|
defaultConfig {
|
|
applicationId = "com.onlinemsg.client"
|
|
minSdk = 26
|
|
targetSdk = 34
|
|
versionCode = 1
|
|
versionName = "1.0.0.3"
|
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
vectorDrawables {
|
|
useSupportLibrary = true
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
isMinifyEnabled = false
|
|
proguardFiles(
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
"proguard-rules.pro"
|
|
)
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
kotlinOptions {
|
|
jvmTarget = "17"
|
|
}
|
|
|
|
buildFeatures {
|
|
compose = true
|
|
}
|
|
composeOptions {
|
|
kotlinCompilerExtensionVersion = "1.5.14"
|
|
}
|
|
|
|
packaging {
|
|
resources {
|
|
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
getByName("debug") {
|
|
res.srcDir(generatedLocalDebugResDir)
|
|
manifest.srcFile(generatedLocalDebugManifestFile)
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation("androidx.core:core-ktx:1.13.1")
|
|
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.6")
|
|
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.6")
|
|
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.6")
|
|
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.6")
|
|
implementation("androidx.activity:activity-compose:1.9.2")
|
|
implementation("com.google.android.material:material:1.12.0")
|
|
|
|
implementation(platform("androidx.compose:compose-bom:2024.09.03"))
|
|
implementation("androidx.compose.ui:ui")
|
|
implementation("androidx.compose.ui:ui-tooling-preview")
|
|
implementation("androidx.compose.material3:material3")
|
|
implementation("androidx.compose.material:material-icons-extended")
|
|
|
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1")
|
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
|
|
implementation("androidx.datastore:datastore-preferences:1.1.1")
|
|
implementation("androidx.room:room-runtime:2.6.1")
|
|
implementation("androidx.room:room-ktx:2.6.1")
|
|
ksp("androidx.room:room-compiler:2.6.1")
|
|
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
|
|
|
debugImplementation("androidx.compose.ui:ui-tooling")
|
|
debugImplementation("androidx.compose.ui:ui-test-manifest")
|
|
|
|
testImplementation("junit:junit:4.13.2")
|
|
androidTestImplementation(platform("androidx.compose:compose-bom:2024.09.03"))
|
|
androidTestImplementation("androidx.test.ext:junit:1.2.1")
|
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
|
|
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
|
|
}
|
|
|
|
val debugApkExportDir: String = providers.gradleProperty("debugApkExportDir")
|
|
.orElse(providers.environmentVariable("DEBUG_APK_EXPORT_DIR"))
|
|
.orElse(layout.buildDirectory.dir("exports/apk-debug").map { it.asFile.absolutePath })
|
|
.get()
|
|
val debugApkExportName = "onlinemsgclient-debug.apk"
|
|
|
|
val prepareLocalDebugTrust by tasks.registering {
|
|
val sourceFile = localDebugCaCertSource
|
|
|
|
inputs.file(sourceFile).optional()
|
|
outputs.dir(generatedLocalDebugTrustDir)
|
|
|
|
doLast {
|
|
generatedLocalDebugTrustRoot.deleteRecursively()
|
|
generatedLocalDebugTrustRoot.mkdirs()
|
|
|
|
if (sourceFile.exists()) {
|
|
val rawDir = generatedLocalDebugResDir.resolve("raw")
|
|
val xmlDir = generatedLocalDebugResDir.resolve("xml")
|
|
rawDir.mkdirs()
|
|
xmlDir.mkdirs()
|
|
|
|
sourceFile.copyTo(rawDir.resolve("local_ca.crt"), overwrite = true)
|
|
xmlDir.resolve("network_security_config.xml").writeText(
|
|
"""
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<network-security-config>
|
|
<base-config>
|
|
<trust-anchors>
|
|
<certificates src="system" />
|
|
<certificates src="@raw/local_ca" />
|
|
</trust-anchors>
|
|
</base-config>
|
|
</network-security-config>
|
|
""".trimIndent() + "\n"
|
|
)
|
|
|
|
generatedLocalDebugManifestFile.writeText(
|
|
"""
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
<application android:networkSecurityConfig="@xml/network_security_config" />
|
|
</manifest>
|
|
""".trimIndent() + "\n"
|
|
)
|
|
} else {
|
|
generatedLocalDebugManifestFile.writeText(
|
|
"""
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
""".trimIndent() + "\n"
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
val exportDebugApk by tasks.registering(Copy::class) {
|
|
from(layout.buildDirectory.file("outputs/apk/debug/app-debug.apk"))
|
|
into(debugApkExportDir)
|
|
rename { debugApkExportName }
|
|
doFirst {
|
|
file(debugApkExportDir).mkdirs()
|
|
}
|
|
}
|
|
|
|
tasks.matching { it.name == "preDebugBuild" }.configureEach {
|
|
dependsOn(prepareLocalDebugTrust)
|
|
}
|
|
|
|
tasks.matching { it.name == "assembleDebug" }.configureEach {
|
|
dependsOn(prepareLocalDebugTrust)
|
|
finalizedBy(exportDebugApk)
|
|
}
|