2021-05-14 19:51:08 +03:00
|
|
|
@file:Suppress("UNUSED_VARIABLE")
|
|
|
|
|
2021-09-11 09:53:09 +03:00
|
|
|
import com.android.build.gradle.BaseExtension
|
2021-09-12 06:04:26 +03:00
|
|
|
import com.github.benmanes.gradle.versions.VersionsPlugin
|
|
|
|
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
|
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 {
|
2021-09-12 06:04:26 +03:00
|
|
|
gradlePluginPortal()
|
2021-09-11 09:53:09 +03:00
|
|
|
mavenCentral()
|
|
|
|
google()
|
|
|
|
maven("https://maven.kr328.app/releases")
|
|
|
|
}
|
|
|
|
dependencies {
|
2021-09-12 06:04:26 +03:00
|
|
|
classpath(deps.build.update)
|
2021-09-11 09:53:09 +03:00
|
|
|
classpath(deps.build.android)
|
|
|
|
classpath(deps.build.kotlin.common)
|
|
|
|
classpath(deps.build.kotlin.serialization)
|
|
|
|
classpath(deps.build.ksp)
|
|
|
|
classpath(deps.build.golang)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-14 19:51:08 +03:00
|
|
|
allprojects {
|
2021-09-12 06:04:26 +03:00
|
|
|
apply {
|
|
|
|
plugin(VersionsPlugin::class)
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(DependencyUpdatesTask::class) {
|
|
|
|
val rejectPattern = Regex("(beta|alpha)", RegexOption.IGNORE_CASE)
|
|
|
|
|
|
|
|
rejectVersionIf {
|
|
|
|
candidate.version.contains(rejectPattern)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
subprojects {
|
|
|
|
val isApp = name == "app"
|
|
|
|
|
|
|
|
apply(plugin = if (isApp) "com.android.application" else "com.android.library")
|
|
|
|
|
|
|
|
extensions.configure(BaseExtension::class) {
|
|
|
|
val minSdkVersion = 21
|
|
|
|
val targetSdkVersion = 30
|
|
|
|
val buildVersionCode = 204009
|
|
|
|
val buildVersionName = "2.4.9"
|
|
|
|
val defaultDimension = "feature"
|
|
|
|
|
|
|
|
ndkVersion = "23.0.7599858"
|
|
|
|
|
|
|
|
compileSdkVersion(targetSdkVersion)
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
if (isApp) {
|
|
|
|
applicationId = "com.github.kr328.clash"
|
|
|
|
}
|
|
|
|
|
|
|
|
minSdk = minSdkVersion
|
|
|
|
targetSdk = targetSdkVersion
|
|
|
|
|
|
|
|
versionName = buildVersionName
|
|
|
|
versionCode = buildVersionCode
|
|
|
|
|
|
|
|
if (!isApp) {
|
|
|
|
consumerProguardFiles("consumer-rules.pro")
|
|
|
|
}
|
|
|
|
|
|
|
|
resValue("string", "release_name", "v$buildVersionName")
|
|
|
|
resValue("integer", "release_code", "$buildVersionCode")
|
|
|
|
|
|
|
|
externalNativeBuild {
|
|
|
|
cmake {
|
|
|
|
abiFilters("arm64-v8a", "armeabi-v7a", "x86", "x86_64")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isApp) {
|
|
|
|
packagingOptions {
|
|
|
|
excludes.add("DebugProbesKt.bin")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
named("release") {
|
|
|
|
isMinifyEnabled = isApp
|
|
|
|
isShrinkResources = isApp
|
|
|
|
proguardFiles(
|
|
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
|
|
"proguard-rules.pro"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
productFlavors {
|
|
|
|
flavorDimensions(defaultDimension)
|
|
|
|
|
|
|
|
create("foss") {
|
|
|
|
dimension = defaultDimension
|
|
|
|
versionNameSuffix = ".foss"
|
|
|
|
|
|
|
|
if (isApp) {
|
|
|
|
applicationIdSuffix = ".foss"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
create("premium") {
|
|
|
|
dimension = defaultDimension
|
|
|
|
versionNameSuffix = ".premium"
|
2021-09-11 20:33:52 +03:00
|
|
|
|
|
|
|
val trackFile = rootProject.file("track.properties")
|
|
|
|
if (trackFile.exists()) {
|
|
|
|
val track = Properties().apply {
|
|
|
|
trackFile.inputStream().use(this::load)
|
|
|
|
}
|
|
|
|
|
|
|
|
buildConfigField("String", "APP_CENTER_KEY", "\"${track.getProperty("appcenter.key")!!}\"")
|
|
|
|
} else {
|
|
|
|
buildConfigField("String", "APP_CENTER_KEY", "null")
|
|
|
|
}
|
2021-09-11 09:53:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildFeatures.apply {
|
|
|
|
dataBinding {
|
|
|
|
isEnabled = name != "hideapi"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isApp) {
|
|
|
|
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
|
|
|
|
|
|
|
tasks.named<Wrapper>("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")
|
|
|
|
}
|
|
|
|
}
|