-
-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathbuild.gradle
330 lines (282 loc) · 12 KB
/
build.gradle
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
plugins {
id 'com.android.application'
id 'com.google.devtools.ksp'
// to download blocklists for the headless variant
id "de.undercouch.download" version "5.3.0"
id 'kotlin-android'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}
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 34
// https://developer.android.com/studio/build/configure-app-module
namespace 'com.celzero.bravedns'
defaultConfig {
applicationId "com.celzero.bravedns"
minSdkVersion 23
targetSdkVersion 34
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")
}
}
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']
}
}
variantFilter { variant ->
def releaseChannel = variant.getFlavors().get(0).name
def releaseType = variant.getFlavors().get(1).name
if (releaseType == 'headless' && releaseChannel != 'fdroid') {
variant.setIgnore(true)
}
}
flavorDimensions = ["releaseChannel", "releaseType"]
productFlavors {
play {
dimension "releaseChannel"
}
fdroid {
dimension "releaseChannel"
}
website {
dimension "releaseChannel"
}
headless {
dimension "releaseType"
minSdkVersion 31
// stackoverflow.com/a/60560178
// buildConfigField 'string', 'timestamp', '1662384683026'
}
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 buildtype alpha, versionCode is set in env overriding gradle.properties
versionCode = getVersionCode()
versionName = gitVersion
vectorDrawables.useSupportLibrary = true
}
}
lint {
abortOnError false
}
tasks.configureEach { task ->
if (task.name.toLowerCase().contains('headless')) {
task.dependsOn downloadBlocklists
if (task.name.endsWith("BuildConfig")) {
task.enabled false
}
}
}
}
configurations {
download {
transitive false
}
}
dependencies {
androidTestImplementation 'androidx.test:rules:1.5.0'
def room_version = "2.6.1"
def paging_version = "3.2.1"
implementation 'com.google.guava:guava:32.1.1-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:1.9.21'
fullImplementation 'androidx.appcompat:appcompat:1.6.1'
fullImplementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
fullImplementation 'androidx.constraintlayout:constraintlayout:2.1.4'
fullImplementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
fullImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
fullImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
// LiveData
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.7.0'
implementation 'com.google.code.gson:gson:2.10.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.7.0'
fullImplementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
// Pagers Views
implementation "androidx.paging:paging-runtime-ktx:$paging_version"
fullImplementation 'androidx.fragment:fragment-ktx:1.6.2'
implementation 'com.google.android.material:material:1.11.0'
fullImplementation 'androidx.viewpager2:viewpager2:1.0.0'
fullImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
fullImplementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0'
fullImplementation 'com.squareup.retrofit2:retrofit:2.9.0'
fullImplementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okio:okio-jvm:3.9.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:3.5.6'
implementation 'io.insert-koin:koin-core:3.5.6'
// Koin main (Scope, ViewModel ...)
download 'io.insert-koin:koin-android:3.5.6'
implementation 'io.insert-koin:koin-android:3.5.6'
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'
// from: https://jitpack.io/#celzero/firestack
download 'com.github.celzero:firestack:ee0a5ac71f@aar'
websiteImplementation 'com.github.celzero:firestack:ee0a5ac71f@aar'
fdroidImplementation 'com.github.celzero:firestack:ee0a5ac71f@aar'
// debug symbols for crashlytics
playImplementation 'com.github.celzero:firestack:ee0a5ac71f:debug@aar'
// Work manager
implementation('androidx.work:work-runtime-ktx:2.9.0') {
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
// https://seancfoley.github.io/IPAddress/ipaddress.html
download 'com.github.seancfoley:ipaddress:5.4.0'
implementation 'com.github.seancfoley:ipaddress:5.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
leakCanaryImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
fullImplementation 'androidx.navigation:navigation-fragment-ktx:2.7.7'
fullImplementation 'androidx.navigation:navigation-ui-ktx:2.7.7'
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-alpha06")
implementation("androidx.security:security-app-authenticator:1.0.0-alpha03")
androidTestImplementation("androidx.security:security-app-authenticator:1.0.0-alpha03")
// barcode scanner for wireguard
fullImplementation 'com.journeyapps:zxing-android-embedded:4.3.0'
// only using firebase crashlytics experimentally for stability tracking, only in play variant
// not in fdroid or website
playImplementation 'com.google.firebase:firebase-crashlytics:19.0.0'
playImplementation 'com.google.firebase:firebase-crashlytics-ndk:19.0.0'
}
// github.com/michel-kraemer/gradle-download-task/issues/131#issuecomment-464476903
tasks.register('downloadBlocklists', Download) {
// def assetsDir = new File(projectDir, 'src/main/assets'
def assetsDir = android.sourceSets.headless.assets.srcDirs[0]
// the filenames are ignored by dl, but acts as a hint for the output
// filename for the download-plugin, which does not respect the
// content-disposition http header, but rather guesses dest file names
// from the final segment of url's path
// github.com/michel-kraemer/gradle-download-task/blob/64d1ce32/src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java#L731
def sources = [
'https://dl.rethinkdns.com/blocklists/filetag.json',
'https://dl.rethinkdns.com/basicconfig/basicconfig.json',
'https://dl.rethinkdns.com/rank/rd.txt',
'https://dl.rethinkdns.com/trie/td.txt',
]
src(sources)
dest assetsDir
// download files only if last-modified of the local file is less than
// the last-modified http header returned by the server
onlyIfModified true
// or if etag mismatches
useETag true
// overwrite older files as determined by last-modified, always
overwrite true
}
tasks.register('downloadDependencies', Copy) {
dependsOn downloadBlocklists
from configurations.download
into "libs"
}