forked from Dr-TSNG/Hide-My-Applist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
120 lines (102 loc) · 3.58 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.gradle.BaseExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.konan.properties.Properties
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath(kotlin("gradle-plugin", version = "1.7.20"))
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3")
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.google.gms:google-services:4.3.14")
}
}
plugins {
id("com.android.application") apply false
id("com.android.library") apply false
kotlin("android") apply false
}
fun String.execute(currentWorkingDir: File = file("./")): String {
val byteOut = java.io.ByteArrayOutputStream()
project.exec {
workingDir = currentWorkingDir
commandLine = split("\\s".toRegex())
standardOutput = byteOut
}
return String(byteOut.toByteArray()).trim()
}
val minSdkVer by extra(24)
val targetSdkVer by extra(33)
val buildToolsVer by extra("33.0.1")
val appVerName by extra("3.0.6")
val serviceVerCode by extra(90)
val minBackupVerCode by extra(65)
val androidSourceCompatibility = JavaVersion.VERSION_11
val androidTargetCompatibility = JavaVersion.VERSION_11
val gitCommitCount = "git rev-list HEAD --count".execute().toInt()
val gitCommitHash = "git rev-parse --verify --short HEAD".execute()
val localProperties = Properties()
localProperties.load(file("local.properties").inputStream())
val officialBuild by extra(localProperties.getProperty("officialBuild", "false") == "true")
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
fun Project.configureBaseExtension() {
extensions.findByType<BaseExtension>()?.run {
compileSdkVersion(targetSdkVer)
buildToolsVersion = buildToolsVer
defaultConfig {
minSdk = minSdkVer
targetSdk = targetSdkVer
versionCode = gitCommitCount
versionName = appVerName
if (localProperties.getProperty("buildWithGitSuffix").toBoolean())
versionNameSuffix = ".r${gitCommitCount}.${gitCommitHash}"
consumerProguardFiles("proguard-rules.pro")
}
val config = localProperties.getProperty("fileDir")?.let {
signingConfigs.create("config") {
storeFile = file(it)
storePassword = localProperties.getProperty("storePassword")
keyAlias = localProperties.getProperty("keyAlias")
keyPassword = localProperties.getProperty("keyPassword")
}
}
buildTypes {
all {
signingConfig = config ?: signingConfigs["debug"]
}
named("release") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}
}
extensions.findByType<ApplicationExtension>()?.run {
buildTypes {
named("release") {
isShrinkResources = true
}
}
}
extensions.findByType<KotlinCompile>()?.run {
kotlinOptions {
jvmTarget = "11"
}
}
}
subprojects {
plugins.withId("com.android.application") {
configureBaseExtension()
}
plugins.withId("com.android.library") {
configureBaseExtension()
}
}