forked from celzero/rethink-app
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.gradle
More file actions
332 lines (286 loc) · 12.3 KB
/
build.gradle
File metadata and controls
332 lines (286 loc) · 12.3 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
plugins {
id 'com.android.application'
id 'com.google.devtools.ksp'
id 'kotlin-android'
}
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
// https://github.com/celzero/rethink-app/issues/1032
// https://docs.gradle.org/8.2/userguide/configuration_cache.html#config_cache:requirements:external_processes
// get the git version from the command line
def gitVersion = providers.exec {
commandLine("git", "describe", "--tags", "--always")
}.standardOutput.asText.get().toString().trim()
// for github builds, the version code is set in the github action via env
// for local builds, the version code is set in gradle.properties
def getVersionCode = {
def code = 0
try {
// parseInt throws NumberFormatException if the string does not contain a parsable integer
// but "as Integer" is a wrapper class, which silently returns null
code = Integer.parseInt(System.getenv("VERSION_CODE"))
logger.info("env version code: $code")
} catch (NumberFormatException ex) {
logger.info("missing env version code: $ex.message")
}
if (code == 0) {
code = project.properties['VERSION_CODE'] as Integer
logger.info("project properties version code: $code")
}
return code
}
try {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
} catch (Exception ex) {
logger.info("missing keystore prop: $ex.message")
keystoreProperties['keyAlias'] = ''
keystoreProperties['keyPassword'] = ''
keystoreProperties['storeFile'] = '/dev/null'
keystoreProperties['storePassword'] = ''
}
android {
compileSdk 35
// https://developer.android.com/studio/build/configure-app-module
namespace 'com.celzero.bravedns'
defaultConfig {
applicationId "com.celzero.bravedns"
minSdkVersion 23
targetSdkVersion 35
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
config {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
// archive.is/wlwD8
alpha {
keyAlias System.getenv("ALPHA_KS_ALIAS") // rdnsAlpha
keyPassword System.getenv("ALPHA_KS_PASSPHRASE")
// https://stackoverflow.com/a/34640602
storeFile file(String.valueOf(System.getenv("ALPHA_KS_FILE"))) // rdnsAlpha.jks in app/
storePassword System.getenv("ALPHA_KS_STORE_PASSPHRASE")
}
}
// https://developer.android.com/studio/build/configure-apk-splits
splits.abi {
println('Create separate apks')
// generates multiple APKs based on the ABIs you define
enable true
reset()
// comma-separated list of ABIs that you want Gradle to generate APKs for
include 'x86', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86_64'
// generates a universal APK in addition to per-ABI APKs
universalApk true
}
// version codes for each ABI variant
project.ext.versionCodes = [
'armeabi' : 1,
'armeabi-v7a': 2,
'arm64-v8a' : 3,
'x86' : 8,
'x86_64' : 9
]
android.applicationVariants.configureEach { variant ->
println("variant name: ${variant.name}")
variant.outputs.configureEach { output ->
// def abi = output.filters.find { it.filterType.name == "ABI" }?.identifier
def abi = variant.outputs.first().getFilter(com.android.build.OutputFile.ABI)
def baseAbiVersionCode = project.ext.versionCodes.get(abi)
println("base version code: $baseAbiVersionCode")
if (abi != null) {
println("variant name: ${variant.name}, abi: $abi")
// assign different version code for each output
// eg for arm64-v8a, version code will be 30000000 + variant.versionCode
def v = baseAbiVersionCode * 10000000 + variant.versionCode
// API 'ApkVariantOutput.getVersionCodeOverride()' is obsolete and has been replaced
// with 'VariantOutput.versionCode()'
output.versionCodeOverride = v
println("version code override: $v")
} else {
println("no ABI filter applied for variant: ${variant.name}")
}
}
}
buildTypes {
release {
// modified as part of #352, now webview is removed from app, flipping back
// the setting to true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
leakCanary {
matchingFallbacks = ['debug']
initWith buildTypes.debug
}
alpha {
// archive.is/y8uCB
applicationIdSuffix ".alpha"
minifyEnabled true
shrinkResources true
signingConfig signingConfigs.alpha
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
viewBinding true
buildConfig true
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
packagingOptions {
jniLibs {
keepDebugSymbols += ['**/*.so']
}
}
flavorDimensions = ["releaseChannel", "releaseType"]
productFlavors {
play {
dimension "releaseChannel"
}
fdroid {
dimension "releaseChannel"
}
website {
dimension "releaseChannel"
}
full {
dimension "releaseType"
// getPackageInfo().versionCode not returning the correct value (in prod builds) when
// value is set in AndroidManifest.xml so setting it here
// for build type alpha, versionCode is set in env overriding gradle.properties
versionCode = getVersionCode()
versionName = gitVersion
vectorDrawables.useSupportLibrary = true
}
}
lint {
abortOnError true
}
}
configurations {
download {
transitive false
}
}
def firestackRepo = project.findProperty("firestackRepo") ?: "github"
def firestackCommit = project.findProperty("firestackCommit") ?: "main"
def firestackDependency = { suffix = "" ->
switch (firestackRepo) {
case "jitpack":
return "com.github.celzero:firestack:$firestackCommit${suffix}@aar"
case "github":
return "com.github.celzero:firestack:$firestackCommit${suffix}"
case "ossrh":
return "com.celzero:firestack:$firestackCommit${suffix}@aar"
default:
throw new GradleException("Unknown firestackRepo: $firestackRepo")
}
}
dependencies {
def room_version = "2.6.1"
def paging_version = "3.3.6"
implementation 'com.google.guava:guava:33.4.8-android'
// https://developer.android.com/studio/write/java8-support
// included to fix issues with Android 6 support, issue#563
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
fullImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.0'
fullImplementation 'androidx.appcompat:appcompat:1.7.1'
fullImplementation 'androidx.core:core-ktx:1.16.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
fullImplementation 'androidx.constraintlayout:constraintlayout:2.2.1'
fullImplementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
fullImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2'
fullImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2'
// LiveData
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.9.1'
implementation 'com.google.code.gson:gson:2.13.1'
implementation "androidx.room:room-runtime:$room_version"
ksp "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-paging:$room_version"
fullImplementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
fullImplementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.1'
fullImplementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.9.1'
// Pagers Views
implementation "androidx.paging:paging-runtime-ktx:$paging_version"
fullImplementation 'androidx.fragment:fragment-ktx:1.8.8'
implementation 'com.google.android.material:material:1.12.0'
fullImplementation 'androidx.viewpager2:viewpager2:1.1.0'
fullImplementation 'com.squareup.okhttp3:okhttp:5.1.0'
fullImplementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:5.1.0'
fullImplementation 'com.squareup.retrofit2:retrofit:3.0.0'
fullImplementation 'com.squareup.retrofit2:converter-gson:3.0.0'
implementation 'com.squareup.okio:okio-jvm:3.15.0'
// Glide
fullImplementation('com.github.bumptech.glide:glide:4.16.0') {
exclude group: 'glide-parent'
}
fullImplementation('com.github.bumptech.glide:okhttp3-integration:4.16.0') {
exclude group: 'glide-parent'
}
// Ref: https://stackoverflow.com/a/46638213
kspFull 'com.github.bumptech.glide:compiler:4.16.0'
// Swipe button animation
fullImplementation 'com.facebook.shimmer:shimmer:0.5.0'
// Koin core
download 'io.insert-koin:koin-core:4.1.0'
implementation 'io.insert-koin:koin-core:4.1.0'
// Koin main (Scope, ViewModel ...)
download 'io.insert-koin:koin-android:4.1.0'
implementation 'io.insert-koin:koin-android:4.1.0'
download 'hu.autsoft:krate:2.0.0'
implementation 'hu.autsoft:krate:2.0.0'
// viewBinding without reflection
fullImplementation 'com.github.kirich1409:viewbindingpropertydelegate:1.5.9'
fullImplementation 'com.github.kirich1409:viewbindingpropertydelegate-noreflection:1.5.9'
// add ":debug" suffix to the dependency to include debug symbols
download firestackDependency()
websiteImplementation firestackDependency()
fdroidImplementation firestackDependency()
playImplementation firestackDependency()
// Work manager
implementation('androidx.work:work-runtime-ktx:2.10.2') {
modules {
module("com.google.guava:listenablefuture") {
replacedBy("com.google.guava:guava", "listenablefuture is part of guava")
}
}
}
// for handling IP addresses and subnets, both IPv4 and IPv6
// seancfoley.github.io/IPAddress/ipaddress.html
download 'com.github.seancfoley:ipaddress:5.5.1'
implementation 'com.github.seancfoley:ipaddress:5.5.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'androidx.test:rules:1.6.1'
leakCanaryImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
fullImplementation 'androidx.navigation:navigation-fragment-ktx:2.9.1'
fullImplementation 'androidx.navigation:navigation-ui-ktx:2.9.1'
fullImplementation 'androidx.biometric:biometric:1.1.0'
playImplementation 'com.google.android.play:app-update:2.1.0'
playImplementation 'com.google.android.play:app-update-ktx:2.1.0'
// for encrypting wireguard configuration files
implementation("androidx.security:security-crypto:1.1.0-beta01")
implementation("androidx.security:security-app-authenticator:1.0.0-rc01")
androidTestImplementation("androidx.security:security-app-authenticator:1.0.0-rc01")
// barcode scanner for wireguard
fullImplementation 'com.journeyapps:zxing-android-embedded:4.3.0'
fullImplementation 'com.simplecityapps:recyclerview-fastscroll:2.0.1'
// for confetti animation
fullImplementation 'nl.dionsegijn:konfetti-xml:2.0.5'
// for in-app purchases
//playImplementation 'com.android.billingclient:billing:8.0.0'
//websiteImplementation 'com.android.billingclient:billing:8.0.0'
// for stripe payment gateway
//websiteImplementation 'com.stripe:stripe-android:21.21.0'
//fdroidImplementation 'com.stripe:stripe-android:21.21.0'
lintChecks 'com.android.security.lint:lint:1.0.3'
}