2021-05-14 19:51:08 +03:00
|
|
|
@file:Suppress("UNUSED_VARIABLE")
|
|
|
|
|
2021-09-17 06:19:03 +03:00
|
|
|
import com.android.build.gradle.AppExtension
|
2021-09-11 09:53:09 +03:00
|
|
|
import com.android.build.gradle.BaseExtension
|
2021-05-15 14:15:43 +03:00
|
|
|
import java.net.URL
|
2021-09-11 20:33:52 +03:00
|
|
|
import java.util.*
|
2021-05-15 14:15:43 +03:00
|
|
|
|
2021-09-11 09:53:09 +03:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
google()
|
|
|
|
maven("https://maven.kr328.app/releases")
|
|
|
|
}
|
|
|
|
dependencies {
|
2022-03-22 08:48:02 +03: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 09:53:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-22 08:48:02 +03:00
|
|
|
subprojects {
|
2021-05-14 19:51:08 +03:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
2021-09-12 06:04:26 +03:00
|
|
|
google()
|
2021-09-11 09:53:09 +03:00
|
|
|
maven("https://maven.kr328.app/releases")
|
|
|
|
}
|
|
|
|
|
|
|
|
val isApp = name == "app"
|
|
|
|
|
|
|
|
apply(plugin = if (isApp) "com.android.application" else "com.android.library")
|
|
|
|
|
2021-09-13 12:49:23 +03:00
|
|
|
extensions.configure<BaseExtension> {
|
2021-09-11 09:53:09 +03:00
|
|
|
defaultConfig {
|
|
|
|
if (isApp) {
|
|
|
|
applicationId = "com.github.kr328.clash"
|
|
|
|
}
|
|
|
|
|
2022-01-14 18:20:01 +03:00
|
|
|
minSdk = 21
|
|
|
|
targetSdk = 31
|
2021-09-11 09:53:09 +03:00
|
|
|
|
2022-05-13 08:50:39 +03:00
|
|
|
versionName = "2.5.9"
|
|
|
|
versionCode = 205009
|
2021-09-11 09:53:09 +03:00
|
|
|
|
2022-01-14 18:20:01 +03:00
|
|
|
resValue("string", "release_name", "v$versionName")
|
|
|
|
resValue("integer", "release_code", "$versionCode")
|
2021-09-11 09:53:09 +03:00
|
|
|
|
|
|
|
externalNativeBuild {
|
|
|
|
cmake {
|
|
|
|
abiFilters("arm64-v8a", "armeabi-v7a", "x86", "x86_64")
|
|
|
|
}
|
|
|
|
}
|
2021-09-12 08:01:08 +03:00
|
|
|
|
|
|
|
if (!isApp) {
|
|
|
|
consumerProguardFiles("consumer-rules.pro")
|
2021-09-17 06:19:03 +03:00
|
|
|
} else {
|
|
|
|
setProperty("archivesBaseName", "cfa-$versionName")
|
2021-09-12 08:01:08 +03:00
|
|
|
}
|
2021-09-11 09:53:09 +03:00
|
|
|
}
|
|
|
|
|
2022-01-14 18:20:01 +03:00
|
|
|
ndkVersion = "23.0.7599858"
|
|
|
|
|
|
|
|
compileSdkVersion(defaultConfig.targetSdk!!)
|
|
|
|
|
2021-09-11 09:53:09 +03:00
|
|
|
if (isApp) {
|
|
|
|
packagingOptions {
|
|
|
|
excludes.add("DebugProbesKt.bin")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
productFlavors {
|
2022-01-14 18:20:01 +03:00
|
|
|
flavorDimensions("feature")
|
2021-09-11 09:53:09 +03:00
|
|
|
|
|
|
|
create("foss") {
|
2021-11-14 14:45:33 +03:00
|
|
|
isDefault = true
|
2022-01-14 18:20:01 +03:00
|
|
|
dimension = flavorDimensionList[0]
|
2021-09-11 09:53:09 +03:00
|
|
|
versionNameSuffix = ".foss"
|
|
|
|
|
2021-09-12 08:01:08 +03:00
|
|
|
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
|
|
|
|
|
2021-09-11 09:53:09 +03:00
|
|
|
if (isApp) {
|
|
|
|
applicationIdSuffix = ".foss"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
create("premium") {
|
2022-01-14 18:20:01 +03:00
|
|
|
dimension = flavorDimensionList[0]
|
2021-09-11 09:53:09 +03:00
|
|
|
versionNameSuffix = ".premium"
|
2021-09-11 20:33:52 +03:00
|
|
|
|
2021-09-12 08:01:08 +03:00
|
|
|
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"true\")")
|
|
|
|
|
2021-09-12 08:19:40 +03:00
|
|
|
val tracker = rootProject.file("tracker.properties")
|
|
|
|
if (tracker.exists()) {
|
|
|
|
val prop = Properties().apply {
|
|
|
|
tracker.inputStream().use(this::load)
|
2021-09-11 20:33:52 +03:00
|
|
|
}
|
|
|
|
|
2021-09-17 06:19:03 +03:00
|
|
|
buildConfigField(
|
|
|
|
"String",
|
|
|
|
"APP_CENTER_KEY",
|
|
|
|
"\"${prop.getProperty("appcenter.key")!!}\""
|
|
|
|
)
|
2021-09-11 20:33:52 +03:00
|
|
|
}
|
2021-09-11 09:53:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-12 08:19:40 +03:00
|
|
|
signingConfigs {
|
|
|
|
val keystore = rootProject.file("signing.properties")
|
|
|
|
if (keystore.exists()) {
|
|
|
|
create("release") {
|
|
|
|
val prop = Properties().apply {
|
|
|
|
keystore.inputStream().use(this::load)
|
|
|
|
}
|
|
|
|
|
|
|
|
storeFile = rootProject.file(prop.getProperty("keystore.path")!!)
|
|
|
|
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 09:53:09 +03:00
|
|
|
buildFeatures.apply {
|
|
|
|
dataBinding {
|
|
|
|
isEnabled = name != "hideapi"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-21 08:38:01 +03:00
|
|
|
variantFilter {
|
|
|
|
ignore = name.startsWith("premium") && !project(":core")
|
|
|
|
.file("src/premium/golang/clash/go.mod").exists()
|
|
|
|
}
|
|
|
|
|
2021-09-11 09:53:09 +03:00
|
|
|
if (isApp) {
|
2021-09-17 06:19:03 +03:00
|
|
|
this as AppExtension
|
|
|
|
|
2021-09-11 09:53:09 +03:00
|
|
|
splits {
|
|
|
|
abi {
|
|
|
|
isEnable = true
|
|
|
|
isUniversalApk = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-14 19:51:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task("clean", type = Delete::class) {
|
|
|
|
delete(rootProject.buildDir)
|
|
|
|
}
|
2021-05-15 14:15:43 +03:00
|
|
|
|
2021-09-13 12:49:23 +03:00
|
|
|
tasks.wrapper {
|
2021-05-15 14:15:43 +03: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")
|
|
|
|
}
|
|
|
|
}
|