Files
ClashForAndroid/build.gradle.kts
T
tongtong dce9562944 Chore: 切换 clash 内核到自有仓库并补全本地构建
- .gitmodules: clash-foss 指向 tongtongstudio/Dreamacro_clash,premium 条目注释保留

- 移除 premium gitlink,premium 变体仍由 variantFilter 自动跳过

- 新增 scripts/build-clash-core.ps1,本地构建 4 个 ABI 的 libclash.so

- kaidl 改用本地 mavenLocal 的 1.15;CMake 传入 GO_OUTPUT 并通过 jniLibs 打包 libclash.so
2026-11-26 13:31:55 +08:00

179 lines
5.1 KiB
Kotlin

@file:Suppress("UNUSED_VARIABLE")
import com.android.build.gradle.AppExtension
import com.android.build.gradle.BaseExtension
import java.net.URL
import java.util.*
buildscript {
repositories {
mavenLocal()
// mavenCentral()
google()
// maven("https://maven.kr328.app/releases")
maven("https://jitpack.io")
maven("https://developer.huawei.com/repo/")
maven("https://maven.aliyun.com/repository/central")
maven("https://maven.aliyun.com/repository/jcenter")
maven("https://maven.aliyun.com/repository/public")
maven("https://maven.aliyun.com/repository/google")
}
dependencies {
classpath(libs.build.android)
classpath(libs.build.kotlin.common)
classpath(libs.build.kotlin.serialization)
classpath(libs.build.ksp)
// classpath(libs.build.golang)
}
}
subprojects {
repositories {
mavenLocal()
// mavenCentral()
google()
// maven("https://maven.kr328.app/releases")
maven("https://jitpack.io")
maven("https://developer.huawei.com/repo/")
maven("https://maven.aliyun.com/repository/central")
maven("https://maven.aliyun.com/repository/jcenter")
maven("https://maven.aliyun.com/repository/public")
maven("https://maven.aliyun.com/repository/google")
}
val isApp = name == "app"
apply(plugin = if (isApp) "com.android.application" else "com.android.library")
extensions.configure<BaseExtension> {
defaultConfig {
if (isApp) {
applicationId = "com.github.kr328.clash"
}
minSdk = 21
targetSdk = 31
versionName = "2.5.12"
versionCode = 205012
resValue("string", "release_name", "v$versionName")
resValue("integer", "release_code", "$versionCode")
externalNativeBuild {
cmake {
abiFilters("arm64-v8a", "armeabi-v7a", "x86", "x86_64")
}
}
if (!isApp) {
consumerProguardFiles("consumer-rules.pro")
} else {
setProperty("archivesBaseName", "cfa-$versionName")
}
}
ndkVersion = "23.0.7599858"
compileSdkVersion(defaultConfig.targetSdk!!)
if (isApp) {
packagingOptions {
resources {
excludes.add("DebugProbesKt.bin")
}
}
}
productFlavors {
flavorDimensions("feature")
create("foss") {
isDefault = true
dimension = flavorDimensionList[0]
versionNameSuffix = ".foss"
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
if (isApp) {
applicationIdSuffix = ".foss"
}
}
create("premium") {
dimension = flavorDimensionList[0]
versionNameSuffix = ".premium"
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"true\")")
}
}
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"
}
}
buildFeatures.apply {
dataBinding {
isEnabled = name != "hideapi"
}
}
variantFilter {
ignore = name.startsWith("premium") && !project(":core")
.file("src/premium/golang/clash/go.mod").exists()
}
if (isApp) {
this as AppExtension
splits {
abi {
isEnable = true
isUniversalApk = true
}
}
}
}
}
task("clean", type = Delete::class) {
delete(rootProject.buildDir)
}
tasks.wrapper {
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")
}
}