-
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
476 lines (415 loc) · 18.1 KB
/
build.gradle.kts
File metadata and controls
476 lines (415 loc) · 18.1 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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
/*
* Copyright (c) 2023 to present Androidacy and contributors. Names, logos, icons, and the Androidacy name are all trademarks of Androidacy and may not be used without license. See LICENSE for more information.
*/
@file:Suppress("UnstableApiUsage", "SpellCheckingInspection")
import com.android.build.api.variant.FilterConfiguration.FilterType.ABI
import java.util.Properties
plugins {
// Gradle doesn't allow conditionally enabling/disabling plugins
id("com.android.application")
id("com.mikepenz.aboutlibraries.plugin")
kotlin("android")
id("com.google.devtools.ksp") version "2.1.20-1.0.31"
}
android {
// functions to get git info: gitCommitHash, gitBranch, gitRemote
val gitCommitHash = providers.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
}.standardOutput.asText.get().toString().trim()
val gitBranch = providers.exec {
commandLine("git", "rev-parse", "--abbrev-ref", "HEAD")
}.standardOutput.asText.get().toString().trim()
val gitRemote = providers.exec {
commandLine("git", "config", "--get", "remote.origin.url")
}.standardOutput.asText.get().toString().trim()
val timestamp = System.currentTimeMillis()
namespace = "com.fox2code.mmm"
compileSdk = 35
signingConfigs {
create("release") {
if (File("signing.properties").exists()) {
val properties = Properties().apply {
load(File("signing.properties").reader())
}
storeFile = File(properties.getProperty("storeFilePath"))
storePassword = properties.getProperty("storePassword")
keyPassword = properties.getProperty("keyPassword")
keyAlias = properties.getProperty("keyAlias")
}
}
}
defaultConfig {
applicationId = "com.fox2code.mmm"
minSdk = 26
// app is in maintenance mode, we do not intend to update it to target newer SDKs
//noinspection OldTargetApi
targetSdk = 34
versionCode = 94
versionName = "2.3.8-1"
vectorDrawables {
useSupportLibrary = true
}
multiDexEnabled = true
androidResources {
localeFilters.addAll(
listOf(
"ar",
"bs",
"cs",
"de",
"es-rMX",
"es",
"el",
"fr",
"hu",
"id",
"it",
"ja",
"nl",
"pl",
"pt",
"pt-rBR",
"ru",
"tr",
"uk",
"vi",
"zh",
"zh-rTW"
)
)
}
ksp {
arg("room.schemaLocation", "$projectDir/roomSchemas")
}
}
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
isEnable = true
// Resets the list of ABIs for Gradle to create APKs for to none.
reset()
// Specifies a list of ABIs for Gradle to create APKs for.
include("x86", "x86_64", "arm64-v8a", "armeabi-v7a")
isUniversalApk = true
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
renderscriptOptimLevel = 3
signingConfig = signingConfigs.getByName("release")
multiDexEnabled = true
isDebuggable = false
isJniDebuggable = false
}
getByName("debug") {
applicationIdSuffix = ".debug"
isDebuggable = true
versionNameSuffix = "-debug"
isJniDebuggable = true
isMinifyEnabled = false
isShrinkResources = false
multiDexEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
}
}
flavorDimensions.add("type")
productFlavors {
create("default") {
dimension = "type"
// current timestamp of build
buildConfigField("long", "BUILD_TIME", "$timestamp")
// debug http requests. do not set this to true if you care about performance!!!!!
if (System.getenv("CI") != null) {
buildConfigField("boolean", "DEBUG_HTTP", "true")
} else {
buildConfigField("boolean", "DEBUG_HTTP", "false")
}
// Latest commit hash as BuildConfig.COMMIT_HASH
buildConfigField("String", "COMMIT_HASH", "\"$gitCommitHash\"")
// Get the current branch name as BuildConfig.BRANCH_NAME
buildConfigField("String", "BRANCH_NAME", "\"$gitBranch\"")
// Get remote url as BuildConfig.REMOTE_URL
buildConfigField("String", "REMOTE_URL", "\"$gitRemote\"")
buildConfigField("boolean", "ENABLE_AUTO_UPDATER", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING_PII", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_ANALYTICS", "true")
buildConfigField("boolean", "ENABLE_PROTECTION", "true")
// Get the androidacy client ID from the androidacy.properties
val propertiesA = Properties()
val default = "5KYccdYxWB2RxMq5FTbkWisXi2dS6yFN9R7RVlFCG98FRdz6Mf5ojY2fyJCUlXJZ"
if (project.rootProject.file("androidacy.properties").exists()) {
propertiesA.load(project.rootProject.file("androidacy.properties").reader())
propertiesA.setProperty(
"client_id", propertiesA.getProperty(
"client_id", default
)
)
} else {
propertiesA.setProperty("client_id", default)
}
buildConfigField(
"String", "ANDROIDACY_CLIENT_ID", "\"" + propertiesA.getProperty("client_id") + "\""
)
buildConfigField(
"java.util.List<String>",
"ENABLED_REPOS",
"java.util.Arrays.asList(\"androidacy_repo\")",
)
}
// play variant. pretty similiar to default, but with an empty inital online repo list, and use play_client_id instead of client_id
create("play") {
dimension = "type"
versionNameSuffix = "-play"
applicationId = "com.androidacy.mmm"
// current timestamp of build
buildConfigField("long", "BUILD_TIME", "$timestamp")
// debug http requests. do not set this to true if you care about performance!!!!!
// if env var CI is set to true, this will be true
if (System.getenv("CI") != null) {
buildConfigField("boolean", "DEBUG_HTTP", "true")
} else {
buildConfigField("boolean", "DEBUG_HTTP", "false")
}
// Latest commit hash as BuildConfig.COMMIT_HASH
buildConfigField("String", "COMMIT_HASH", "\"$gitCommitHash\"")
// Get the current branch name as BuildConfig.BRANCH_NAME
buildConfigField("String", "BRANCH_NAME", "\"$gitBranch\"")
// Get remote url as BuildConfig.REMOTE_URL
buildConfigField("String", "REMOTE_URL", "\"$gitRemote\"")
buildConfigField("boolean", "ENABLE_AUTO_UPDATER", "false")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING_PII", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_ANALYTICS", "true")
buildConfigField("boolean", "ENABLE_PROTECTION", "true")
// Get the androidacy client ID from the androidacy.properties
val propertiesA = Properties()
val default = "5KYccdYxWB2RxMq5FTbkWisXi2dS6yFN9R7RVlFCG98FRdz6Mf5ojY2fyJCUlXJZ"
if (project.rootProject.file("androidacy.properties").exists()) {
propertiesA.load(project.rootProject.file("androidacy.properties").reader())
propertiesA.setProperty(
"client_id", propertiesA.getProperty(
"client_id", default
)
)
} else {
propertiesA.setProperty("client_id", "\"" + default + "\"")
}
buildConfigField(
"String", "ANDROIDACY_CLIENT_ID", "\"" + propertiesA.getProperty("client_id") + "\""
)
buildConfigField(
"java.util.List<String>",
"ENABLED_REPOS",
"java.util.Arrays.asList(\"\")",
)
}
create("fdroid") {
dimension = "type"
applicationIdSuffix = ".fdroid"
// current timestamp of build
buildConfigField("long", "BUILD_TIME", "$timestamp")
// debug http requests. do not set this to true if you care about performance!!!!!
if (System.getenv("CI") != null) {
buildConfigField("boolean", "DEBUG_HTTP", "true")
} else {
buildConfigField("boolean", "DEBUG_HTTP", "false")
}
// Latest commit hash as BuildConfig.COMMIT_HASH
buildConfigField("String", "COMMIT_HASH", "\"$gitCommitHash\"")
// Get the current branch name as BuildConfig.BRANCH_NAME
buildConfigField("String", "BRANCH_NAME", "\"$gitBranch\"")
// Get remote url as BuildConfig.REMOTE_URL
buildConfigField("String", "REMOTE_URL", "\"$gitRemote\"")
// Need to disable auto-updater for F-Droid flavor because their inclusion policy
// forbids downloading blobs from third-party websites (and F-Droid APK isn"t signed
// with our keys, so the APK wouldn"t install anyways).
buildConfigField("boolean", "ENABLE_AUTO_UPDATER", "false")
// Disable crash reporting for F-Droid flavor by default
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "false")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING_PII", "false")
buildConfigField("boolean", "DEFAULT_ENABLE_ANALYTICS", "false")
buildConfigField("boolean", "ENABLE_PROTECTION", "true")
// Repo with ads or tracking feature are disabled by default for the
// F-Droid flavor. at the same time, the alt repo isn"t particularly trustworthy
buildConfigField(
"java.util.List<String>",
"ENABLED_REPOS",
"java.util.Arrays.asList(\"\")",
)
// Get the androidacy client ID from the androidacy.properties
val propertiesA = Properties()
// If androidacy.properties doesn"t exist, use the fdroid client ID which is limited
// to 50 requests per minute
if (project.rootProject.file("androidacy.properties").exists()) {
propertiesA.load(project.rootProject.file("androidacy.properties").inputStream())
} else {
propertiesA.setProperty(
"client_id", "dQ1p7X8bF14PVJ7wAU6ORVjPB2IeTinsuAZ8Uos6tQiyUdUyIjSyZSmN54QBbaTy"
)
}
buildConfigField(
"String", "ANDROIDACY_CLIENT_ID", "\"" + propertiesA.getProperty(
"client_id", "dQ1p7X8bF14PVJ7wAU6ORVjPB2IeTinsuAZ8Uos6tQiyUdUyIjSyZSmN54QBbaTy"
) + "\""
)
versionNameSuffix = "-fdroid"
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
lint {
disable.add("MissingTranslation")
}
}
val abiCodes = mapOf("armeabi-v7a" to 1, "x86" to 2, "x86_64" to 3, "arm64-v8a" to 4)
// For per-density APKs, create a similar map:
// val densityCodes = mapOf("mdpi" to 1, "hdpi" to 2, "xhdpi" to 3)
// For each APK output variant, override versionCode with a combination of
// abiCodes * 1000 + variant.versionCode. In this example, variant.versionCode
// is equal to defaultConfig.versionCode. If you configure product flavors that
// define their own versionCode, variant.versionCode uses that value instead.
androidComponents {
onVariants { variant ->
// Assigns a different version code for each output APK
// other than the universal APK.
variant.outputs.forEach { output ->
val name = output.filters.find { it.filterType == ABI }?.identifier
// Stores the value of abiCodes that is associated with the ABI for this variant.
val baseAbiCode = abiCodes[name]
// Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes,
// the following code doesn't override the version code for universal APKs.
// However, because you want universal APKs to have the lowest version code,
// this outcome is desirable.
if (baseAbiCode != null) {
// Assigns the new version code to output.versionCode, which changes the version code
// for only the output APK, not for the variant itself.
val versioCode = output.versionCode.get()
output.versionCode.set((baseAbiCode * 1000) + versioCode)
}
}
}
}
aboutLibraries {
// Specify the additional licenses
additionalLicenses = arrayOf("LGPL_3_0_only", "Apache_2_0")
}
configurations {
// Access all imported libraries
all {
// Exclude all libraries with the following group and module
exclude(group = "org.jetbrains", module = "annotations-java5")
}
}
dependencies {
// UI
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.activity:activity-ktx:1.10.1")
implementation("androidx.emoji2:emoji2:1.5.0")
implementation("androidx.emoji2:emoji2-views-helper:1.5.0")
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("androidx.constraintlayout:constraintlayout:2.2.1")
implementation("androidx.recyclerview:recyclerview:1.4.0")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.webkit:webkit:1.13.0")
implementation("com.google.android.material:material:1.12.0")
implementation("com.mikepenz:aboutlibraries:11.6.3")
// Utils
implementation("androidx.work:work-runtime:2.10.0")
implementation("com.squareup.okhttp3:okhttp:5.0.0-alpha.14")
implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:5.0.0-alpha.14")
// logging interceptor
debugImplementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.14")
// Chromium cronet from androidacy
// implementation("com.google.android.gms:play-services-cronet:18.1.0")
implementation("org.chromium.net:cronet-embedded:119.6045.31")
val libsuVersion = "6.0.0"
// The core module that provides APIs to a shell
implementation("com.github.topjohnwu.libsu:core:${libsuVersion}")
// Optional: APIs for creating root services. Depends on ":core"
implementation("com.github.topjohnwu.libsu:service:${libsuVersion}")
// Optional: Provides remote file system support
implementation("com.github.topjohnwu.libsu:io:${libsuVersion}")
implementation("com.github.Fox2Code:RosettaX:1.0.9")
implementation("com.github.Fox2Code:AndroidANSI:1.2.1")
// Markdown
// TODO: switch to an updated implementation
implementation("io.noties.markwon:core:4.6.2")
implementation("io.noties.markwon:html:4.6.2")
implementation("io.noties.markwon:image:4.6.2")
implementation("io.noties.markwon:syntax-highlight:4.6.2")
implementation("com.google.net.cronet:cronet-okhttp:0.1.0")
implementation("com.caverock:androidsvg:1.4")
implementation("androidx.core:core-ktx:1.15.0")
// timber
implementation("com.jakewharton.timber:timber:5.0.1")
// encryption
implementation("androidx.security:security-crypto:1.1.0-alpha06")
// some utils
implementation("commons-io:commons-io:2.18.0")
implementation("org.apache.commons:commons-compress:1.27.1")
// analytics
implementation("ly.count.android:sdk:25.1.1")
// annotations
implementation("org.jetbrains:annotations-java5:24.1.0")
// debugging
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.14")
// desugaring
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
// yes
implementation("com.github.fingerprintjs:fingerprint-android:2.2.0")
// room
implementation("androidx.room:room-runtime:2.6.1")
// To use Kotlin Symbol Processing (KSP)
ksp("androidx.room:room-compiler:2.6.1")
// optional - Kotlin Extensions and Coroutines support for Room
implementation("androidx.room:room-ktx:2.7.1")
implementation("pl.droidsonroids.gif:android-gif-drawable:1.2.29")
// crash activity
implementation("cat.ereza:customactivityoncrash:2.4.0")
}
android {
sourceSets {
this.getByName("main") {
this.java.srcDir("src/main/kotlin")
}
}
ndkVersion = "28.0.13004108"
dependenciesInfo {
includeInApk = false
includeInBundle = false
}
buildFeatures {
viewBinding = true
buildConfig = true
}
//noinspection GrDeprecatedAPIUsage
kotlinOptions {
jvmTarget = "17"
}
@Suppress("DEPRECATION") packagingOptions {
jniLibs {
useLegacyPackaging = true
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}