2021-05-15 00:51:08 +08:00
|
|
|
@file:Suppress("UNUSED_VARIABLE")
|
|
|
|
|
2021-09-17 11:19:03 +08:00
|
|
|
import com.android.build.gradle.AppExtension
|
2021-09-11 14:53:09 +08:00
|
|
|
import com.android.build.gradle.BaseExtension
|
2021-05-15 19:15:43 +08:00
|
|
|
import java.net.URL
|
2021-09-12 01:33:52 +08:00
|
|
|
import java.util.*
|
2021-05-15 19:15:43 +08:00
|
|
|
|
2021-09-11 14:53:09 +08:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
google()
|
2024-04-19 12:04:19 +08:00
|
|
|
maven("https://raw.githubusercontent.com/MetaCubeX/maven-backup/main/releases")
|
2021-09-11 14:53:09 +08:00
|
|
|
}
|
|
|
|
dependencies {
|
2022-03-22 13:48:02 +08:00
|
|
|
classpath(libs.build.android)
|
|
|
|
classpath(libs.build.kotlin.common)
|
|
|
|
classpath(libs.build.kotlin.serialization)
|
|
|
|
classpath(libs.build.ksp)
|
|
|
|
classpath(libs.build.golang)
|
2021-09-11 14:53:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-22 13:48:02 +08:00
|
|
|
subprojects {
|
2021-05-15 00:51:08 +08:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
2021-09-12 11:04:26 +08:00
|
|
|
google()
|
2024-04-19 12:04:19 +08:00
|
|
|
maven("https://raw.githubusercontent.com/MetaCubeX/maven-backup/main/releases")
|
2021-09-11 14:53:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
val isApp = name == "app"
|
|
|
|
|
|
|
|
apply(plugin = if (isApp) "com.android.application" else "com.android.library")
|
|
|
|
|
2021-09-13 17:49:23 +08:00
|
|
|
extensions.configure<BaseExtension> {
|
2021-09-11 14:53:09 +08:00
|
|
|
defaultConfig {
|
|
|
|
if (isApp) {
|
2022-06-28 17:23:53 +08:00
|
|
|
applicationId = "com.github.metacubex.clash"
|
2021-09-11 14:53:09 +08:00
|
|
|
}
|
|
|
|
|
2022-01-14 23:20:01 +08:00
|
|
|
minSdk = 21
|
|
|
|
targetSdk = 31
|
2021-09-11 14:53:09 +08:00
|
|
|
|
2024-11-03 17:34:45 +08:00
|
|
|
versionName = "2.11.2"
|
|
|
|
versionCode = 211002
|
2021-09-11 14:53:09 +08:00
|
|
|
|
2022-01-14 23:20:01 +08:00
|
|
|
resValue("string", "release_name", "v$versionName")
|
|
|
|
resValue("integer", "release_code", "$versionCode")
|
2021-09-11 14:53:09 +08:00
|
|
|
|
|
|
|
externalNativeBuild {
|
|
|
|
cmake {
|
|
|
|
abiFilters("arm64-v8a", "armeabi-v7a", "x86", "x86_64")
|
|
|
|
}
|
|
|
|
}
|
2021-09-12 13:01:08 +08:00
|
|
|
|
|
|
|
if (!isApp) {
|
|
|
|
consumerProguardFiles("consumer-rules.pro")
|
2021-09-17 11:19:03 +08:00
|
|
|
} else {
|
2022-06-16 15:24:43 +08:00
|
|
|
setProperty("archivesBaseName", "cmfa-$versionName")
|
2021-09-12 13:01:08 +08:00
|
|
|
}
|
2021-09-11 14:53:09 +08:00
|
|
|
}
|
|
|
|
|
2022-01-14 23:20:01 +08:00
|
|
|
ndkVersion = "23.0.7599858"
|
|
|
|
|
|
|
|
compileSdkVersion(defaultConfig.targetSdk!!)
|
|
|
|
|
2021-09-11 14:53:09 +08:00
|
|
|
if (isApp) {
|
|
|
|
packagingOptions {
|
2022-07-01 12:07:23 +08:00
|
|
|
resources {
|
|
|
|
excludes.add("DebugProbesKt.bin")
|
|
|
|
}
|
2021-09-11 14:53:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
productFlavors {
|
2022-01-14 23:20:01 +08:00
|
|
|
flavorDimensions("feature")
|
2021-09-11 14:53:09 +08:00
|
|
|
|
2024-09-12 10:53:54 +08:00
|
|
|
create("alpha") {
|
2021-11-14 19:45:33 +08:00
|
|
|
isDefault = true
|
2022-01-14 23:20:01 +08:00
|
|
|
dimension = flavorDimensionList[0]
|
2024-09-12 10:53:54 +08:00
|
|
|
versionNameSuffix = ".Alpha"
|
2021-09-11 14:53:09 +08:00
|
|
|
|
2022-06-22 19:37:13 +08:00
|
|
|
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
|
2021-09-12 13:01:08 +08:00
|
|
|
|
2024-09-12 14:38:49 +08:00
|
|
|
resValue("string", "launch_name", "@string/launch_name_alpha")
|
|
|
|
resValue("string", "application_name", "@string/application_name_alpha")
|
|
|
|
|
2021-09-11 14:53:09 +08:00
|
|
|
if (isApp) {
|
2024-09-12 10:53:54 +08:00
|
|
|
applicationIdSuffix = ".alpha"
|
2021-09-11 14:53:09 +08:00
|
|
|
}
|
|
|
|
}
|
2023-05-10 18:10:50 +08:00
|
|
|
|
|
|
|
create("meta") {
|
|
|
|
|
|
|
|
dimension = flavorDimensionList[0]
|
|
|
|
versionNameSuffix = ".Meta"
|
|
|
|
|
|
|
|
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
|
|
|
|
|
2024-09-12 14:38:49 +08:00
|
|
|
resValue("string", "launch_name", "@string/launch_name_meta")
|
|
|
|
resValue("string", "application_name", "@string/application_name_meta")
|
|
|
|
|
2023-05-10 18:10:50 +08:00
|
|
|
if (isApp) {
|
|
|
|
applicationIdSuffix = ".meta"
|
|
|
|
}
|
|
|
|
}
|
2022-06-07 15:19:53 +08:00
|
|
|
}
|
2021-09-12 01:33:52 +08:00
|
|
|
|
2022-06-07 15:19:53 +08:00
|
|
|
sourceSets {
|
2023-05-10 18:10:50 +08:00
|
|
|
getByName("meta") {
|
|
|
|
java.srcDirs("src/foss/java")
|
|
|
|
}
|
2024-09-12 10:53:54 +08:00
|
|
|
getByName("alpha") {
|
2022-06-07 15:19:53 +08:00
|
|
|
java.srcDirs("src/foss/java")
|
2021-09-11 14:53:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-12 13:19:40 +08:00
|
|
|
signingConfigs {
|
|
|
|
val keystore = rootProject.file("signing.properties")
|
|
|
|
if (keystore.exists()) {
|
|
|
|
create("release") {
|
|
|
|
val prop = Properties().apply {
|
|
|
|
keystore.inputStream().use(this::load)
|
|
|
|
}
|
|
|
|
|
2022-06-18 10:49:00 +08:00
|
|
|
storeFile = rootProject.file("release.keystore")
|
2021-09-12 13:19:40 +08:00
|
|
|
storePassword = prop.getProperty("keystore.password")!!
|
|
|
|
keyAlias = prop.getProperty("key.alias")!!
|
|
|
|
keyPassword = prop.getProperty("key.password")!!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
named("release") {
|
|
|
|
isMinifyEnabled = isApp
|
|
|
|
isShrinkResources = isApp
|
|
|
|
signingConfig = signingConfigs.findByName("release")
|
|
|
|
proguardFiles(
|
|
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
|
|
"proguard-rules.pro"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
named("debug") {
|
|
|
|
versionNameSuffix = ".debug"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:53:09 +08:00
|
|
|
buildFeatures.apply {
|
|
|
|
dataBinding {
|
|
|
|
isEnabled = name != "hideapi"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isApp) {
|
2021-09-17 11:19:03 +08:00
|
|
|
this as AppExtension
|
|
|
|
|
2021-09-11 14:53:09 +08:00
|
|
|
splits {
|
|
|
|
abi {
|
|
|
|
isEnable = true
|
|
|
|
isUniversalApk = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-15 00:51:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task("clean", type = Delete::class) {
|
|
|
|
delete(rootProject.buildDir)
|
|
|
|
}
|
2021-05-15 19:15:43 +08:00
|
|
|
|
2021-09-13 17:49:23 +08:00
|
|
|
tasks.wrapper {
|
2021-05-15 19:15:43 +08:00
|
|
|
distributionType = Wrapper.DistributionType.ALL
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
val sha256 = URL("$distributionUrl.sha256").openStream()
|
|
|
|
.use { it.reader().readText().trim() }
|
|
|
|
|
|
|
|
file("gradle/wrapper/gradle-wrapper.properties")
|
|
|
|
.appendText("distributionSha256Sum=$sha256")
|
|
|
|
}
|
2022-06-16 15:24:43 +08:00
|
|
|
}
|