mirror of
https://github.com/xtclovver/RKNHardering.git
synced 2026-07-09 17:19:25 +00:00
133 lines
3.7 KiB
Kotlin
133 lines
3.7 KiB
Kotlin
import org.gradle.api.GradleException
|
|
|
|
plugins {
|
|
alias(libs.plugins.android.application)
|
|
}
|
|
|
|
val nativeNdkVersion = "28.2.13676358"
|
|
val nativeCmakeVersion = "3.22.1"
|
|
|
|
val appVersionName = resolveAppVersionName()
|
|
val appVersionCode = calculateAppVersionCode(appVersionName)
|
|
|
|
fun resolveAppVersionName(): String {
|
|
val rawVersion = providers.gradleProperty("appVersionName").orElse("2.0.0").get().trim()
|
|
val normalizedVersion = rawVersion.removePrefix("v")
|
|
|
|
if (!Regex("""\d+\.\d+\.\d+""").matches(normalizedVersion)) {
|
|
throw GradleException("appVersionName must match X.Y.Z, got '$rawVersion'")
|
|
}
|
|
|
|
return normalizedVersion
|
|
}
|
|
|
|
fun calculateAppVersionCode(versionName: String): Int {
|
|
val parts = versionName.split(".")
|
|
val major = parts[0].toInt()
|
|
val minor = parts[1].toInt()
|
|
val patch = parts[2].toInt()
|
|
|
|
if (minor !in 0..99 || patch !in 0..99) {
|
|
throw GradleException(
|
|
"appVersionName supports only minor and patch values from 0 to 99, got '$versionName'"
|
|
)
|
|
}
|
|
|
|
return (major * 10_000) + (minor * 100) + patch
|
|
}
|
|
|
|
android {
|
|
namespace = "com.notcvnt.rknhardering"
|
|
ndkVersion = nativeNdkVersion
|
|
compileSdk {
|
|
version = release(36) {
|
|
minorApiLevel = 1
|
|
}
|
|
}
|
|
|
|
defaultConfig {
|
|
applicationId = "com.notcvnt.rknhardering"
|
|
minSdk = 26
|
|
targetSdk = 36
|
|
versionCode = appVersionCode
|
|
versionName = appVersionName
|
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
androidResources.localeFilters += listOf("en", "ru", "fa", "zh-rCN")
|
|
|
|
ndk {
|
|
abiFilters += listOf("arm64-v8a", "armeabi-v7a", "x86_64")
|
|
}
|
|
|
|
externalNativeBuild {
|
|
cmake {
|
|
arguments += listOf("-DANDROID_STL=c++_static")
|
|
}
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
isMinifyEnabled = false
|
|
proguardFiles(
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
"proguard-rules.pro"
|
|
)
|
|
}
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_11
|
|
targetCompatibility = JavaVersion.VERSION_11
|
|
}
|
|
buildFeatures {
|
|
buildConfig = true
|
|
}
|
|
externalNativeBuild {
|
|
cmake {
|
|
path = file("src/main/cpp/CMakeLists.txt")
|
|
version = nativeCmakeVersion
|
|
}
|
|
}
|
|
packaging {
|
|
jniLibs {
|
|
useLegacyPackaging = false
|
|
}
|
|
}
|
|
testOptions {
|
|
unitTests.isIncludeAndroidResources = true
|
|
}
|
|
}
|
|
|
|
tasks.withType<org.gradle.api.tasks.testing.Test>().configureEach {
|
|
val testHomeDir = layout.projectDirectory.dir(".test-home").asFile
|
|
val tempDir = testHomeDir.resolve("tmp")
|
|
|
|
doFirst {
|
|
testHomeDir.mkdirs()
|
|
tempDir.mkdirs()
|
|
}
|
|
|
|
systemProperty("user.home", testHomeDir.absolutePath)
|
|
systemProperty("java.io.tmpdir", tempDir.absolutePath)
|
|
}
|
|
|
|
dependencies {
|
|
implementation(libs.androidx.core.ktx)
|
|
implementation(libs.androidx.appcompat)
|
|
implementation(libs.material)
|
|
implementation(libs.androidx.activity)
|
|
implementation(libs.androidx.constraintlayout)
|
|
implementation(libs.kotlinx.coroutines.android)
|
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
|
implementation(libs.androidx.lifecycle.viewmodel.ktx)
|
|
implementation(project(":xray-protos"))
|
|
implementation(libs.grpc.okhttp)
|
|
implementation(libs.okhttp)
|
|
implementation(libs.okhttp.dnsoverhttps)
|
|
testImplementation(libs.junit)
|
|
testImplementation(libs.okhttp.mockwebserver)
|
|
testImplementation(libs.robolectric)
|
|
testImplementation(libs.androidx.test.core)
|
|
androidTestImplementation(libs.androidx.junit)
|
|
androidTestImplementation(libs.androidx.espresso.core)
|
|
}
|