1
+ import com.android.build.api.dsl.VariantDimension
1
2
import com.android.build.api.variant.FilterConfiguration
2
3
import java.io.ByteArrayOutputStream
3
4
@@ -24,8 +25,8 @@ configurations.configureEach {
24
25
exclude(module = " commons-logging" )
25
26
}
26
27
27
- val canonicalVersionCode = 415
28
- val canonicalVersionName = " 1.26 .0"
28
+ val canonicalVersionCode = 416
29
+ val canonicalVersionName = " 1.27 .0"
29
30
30
31
val postFixSize = 10
31
32
val abiPostFix = mapOf (
@@ -44,6 +45,39 @@ val getGitHash = providers
44
45
.asText
45
46
.map { it.trim() }
46
47
48
+ val firebaseEnabledVariants = listOf (" play" , " fdroid" )
49
+ val nonPlayVariants = listOf (" fdroid" , " website" ) + if (huaweiEnabled) listOf (" huawei" ) else emptyList()
50
+
51
+ fun VariantDimension.devNetDefaultOn (defaultOn : Boolean ) {
52
+ val fqEnumClass = " org.session.libsession.utilities.Environment"
53
+ buildConfigField(
54
+ fqEnumClass,
55
+ " DEFAULT_ENVIRONMENT" ,
56
+ if (defaultOn) " $fqEnumClass .DEV_NET" else " $fqEnumClass .MAIN_NET"
57
+ )
58
+ }
59
+
60
+ fun VariantDimension.enablePermissiveNetworkSecurityConfig (permissive : Boolean ) {
61
+ manifestPlaceholders[" network_security_config" ] = if (permissive) {
62
+ " @xml/network_security_configuration_permissive"
63
+ } else {
64
+ " @xml/network_security_configuration"
65
+ }
66
+ }
67
+
68
+ fun VariantDimension.setAlternativeAppName (alternative : String? ) {
69
+ if (alternative != null ) {
70
+ manifestPlaceholders[" app_name" ] = alternative
71
+ } else {
72
+ manifestPlaceholders[" app_name" ] = " @string/app_name"
73
+ }
74
+ }
75
+
76
+ fun VariantDimension.setAuthorityPostfix (postfix : String ) {
77
+ manifestPlaceholders[" authority_postfix" ] = postfix
78
+ buildConfigField(" String" , " AUTHORITY_POSTFIX" , " \" $postfix \" " )
79
+ }
80
+
47
81
kotlin {
48
82
compilerOptions {
49
83
jvmToolchain(21 )
@@ -110,27 +144,73 @@ android {
110
144
}
111
145
}
112
146
113
- sourceSets {
114
- val sharedTestDir = " src/sharedTest/java"
115
- getByName(" test" ).java.srcDirs(sharedTestDir)
116
- getByName(" androidTest" ).java.srcDirs(sharedTestDir)
117
-
118
- getByName(" test" ).resources.srcDirs(" $projectDir /src/main/assets" )
119
- }
120
-
121
147
buildTypes {
122
148
getByName(" release" ) {
123
149
isMinifyEnabled = false
150
+
151
+ devNetDefaultOn(false )
152
+ enablePermissiveNetworkSecurityConfig(false )
153
+ setAlternativeAppName(null )
154
+ setAuthorityPostfix(" " )
155
+ }
156
+
157
+ create(" qa" ) {
158
+ initWith(getByName(" release" ))
159
+
160
+ matchingFallbacks + = " release"
161
+
162
+ signingConfig = signingConfigs.getByName(" debug" )
163
+ applicationIdSuffix = " .$name "
164
+
165
+ devNetDefaultOn(false )
166
+ enablePermissiveNetworkSecurityConfig(true )
167
+
168
+ setAlternativeAppName(" Session QA" )
169
+ setAuthorityPostfix(" .qa" )
170
+ }
171
+
172
+ create(" automaticQa" ) {
173
+ initWith(getByName(" qa" ))
174
+
175
+ devNetDefaultOn(true )
176
+ setAlternativeAppName(" Session AQA" )
124
177
}
125
178
126
179
getByName(" debug" ) {
127
180
isDefault = true
128
181
isMinifyEnabled = false
129
182
enableUnitTestCoverage = false
130
183
signingConfig = signingConfigs.getByName(" debug" )
184
+
185
+ applicationIdSuffix = " .${name} "
186
+ enablePermissiveNetworkSecurityConfig(true )
187
+ devNetDefaultOn(false )
188
+ setAlternativeAppName(" Session Debug" )
189
+ setAuthorityPostfix(" .debug" )
131
190
}
132
191
}
133
192
193
+ sourceSets {
194
+ getByName(" test" ).apply {
195
+ java.srcDirs(" $projectDir /src/sharedTest/java" )
196
+ resources.srcDirs(" $projectDir /src/main/assets" )
197
+ }
198
+
199
+ val firebaseCommonDir = " src/firebaseCommon"
200
+ firebaseEnabledVariants.forEach { variant ->
201
+ maybeCreate(variant).java.srcDirs(" $firebaseCommonDir /kotlin" )
202
+ }
203
+
204
+ val nonPlayCommonDir = " src/nonPlayCommon"
205
+ nonPlayVariants.forEach { variant ->
206
+ maybeCreate(variant).apply {
207
+ java.srcDirs(" $nonPlayCommonDir /kotlin" )
208
+ resources.srcDirs(" $nonPlayCommonDir /resources" )
209
+ }
210
+ }
211
+ }
212
+
213
+
134
214
signingConfigs {
135
215
create(" play" ) {
136
216
if (project.hasProperty(" SESSION_STORE_FILE" )) {
@@ -160,39 +240,38 @@ android {
160
240
}
161
241
}
162
242
243
+
163
244
flavorDimensions + = " distribution"
164
245
productFlavors {
165
246
create(" play" ) {
166
247
isDefault = true
167
248
dimension = " distribution"
168
- ext[" websiteUpdateUrl" ] = " null"
169
249
buildConfigField(" boolean" , " PLAY_STORE_DISABLED" , " false" )
170
250
buildConfigField(" org.session.libsession.utilities.Device" , " DEVICE" , " org.session.libsession.utilities.Device.ANDROID" )
171
- buildConfigField(" String" , " NOPLAY_UPDATE_URL" , ext[" websiteUpdateUrl" ] as String )
172
251
buildConfigField(" String" , " PUSH_KEY_SUFFIX" , " \"\" " )
173
252
signingConfig = signingConfigs.getByName(" play" )
174
253
}
175
254
255
+ create(" fdroid" ) {
256
+ initWith(getByName(" play" ))
257
+ }
258
+
176
259
if (huaweiEnabled) {
177
260
create(" huawei" ) {
178
261
dimension = " distribution"
179
- ext[" websiteUpdateUrl" ] = " null"
180
262
buildConfigField(" boolean" , " PLAY_STORE_DISABLED" , " true" )
181
263
buildConfigField(" org.session.libsession.utilities.Device" , " DEVICE" , " org.session.libsession.utilities.Device.HUAWEI" )
182
- buildConfigField(" String" , " NOPLAY_UPDATE_URL" , ext[" websiteUpdateUrl" ] as String )
183
264
buildConfigField(" String" , " PUSH_KEY_SUFFIX" , " \" _HUAWEI\" " )
184
265
signingConfig = signingConfigs.getByName(" huawei" )
185
266
}
186
267
}
187
268
188
269
create(" website" ) {
189
- dimension = " distribution "
190
- ext[ " websiteUpdateUrl " ] = " https://github.com/session-foundation/session-android/releases "
270
+ initWith(getByName( " play " ))
271
+
191
272
buildConfigField(" boolean" , " PLAY_STORE_DISABLED" , " true" )
192
- buildConfigField(" org.session.libsession.utilities.Device" , " DEVICE" , " org.session.libsession.utilities.Device.ANDROID" )
193
- buildConfigField(" String" , " NOPLAY_UPDATE_URL" , " \" ${ext[" websiteUpdateUrl" ]} \" " )
194
- buildConfigField(" String" , " PUSH_KEY_SUFFIX" , " \"\" " )
195
273
}
274
+
196
275
}
197
276
198
277
testOptions {
@@ -251,13 +330,20 @@ dependencies {
251
330
implementation(libs.androidx.fragment.ktx)
252
331
implementation(libs.androidx.core.ktx)
253
332
254
- val playImplementation = configurations.maybeCreate(" playImplementation" )
255
- playImplementation(libs.firebase.messaging) {
256
- exclude(group = " com.google.firebase" , module = " firebase-core" )
257
- exclude(group = " com.google.firebase" , module = " firebase-analytics" )
258
- exclude(group = " com.google.firebase" , module = " firebase-measurement-connector" )
333
+ // Add firebase dependencies to specific variants
334
+ for (variant in firebaseEnabledVariants) {
335
+ val configuration = configurations.maybeCreate(" ${variant} Implementation" )
336
+ configuration(libs.firebase.messaging) {
337
+ exclude(group = " com.google.firebase" , module = " firebase-core" )
338
+ exclude(group = " com.google.firebase" , module = " firebase-analytics" )
339
+ exclude(group = " com.google.firebase" , module = " firebase-measurement-connector" )
340
+ }
259
341
}
260
342
343
+ val playImplementation = configurations.maybeCreate(" playImplementation" )
344
+ playImplementation(libs.google.play.review)
345
+ playImplementation(libs.google.play.review.ktx)
346
+
261
347
if (huaweiEnabled) {
262
348
val huaweiImplementation = configurations.maybeCreate(" huaweiImplementation" )
263
349
huaweiImplementation(libs.huawei.push)
@@ -267,7 +353,6 @@ dependencies {
267
353
implementation(libs.androidx.media3.ui)
268
354
implementation(libs.conscrypt.android)
269
355
implementation(libs.android)
270
- implementation(libs.shortcutbadger)
271
356
implementation(libs.photoview)
272
357
implementation(libs.glide)
273
358
implementation(libs.compose)
@@ -357,7 +442,6 @@ dependencies {
357
442
implementation(libs.androidx.navigation.compose)
358
443
359
444
implementation(libs.accompanist.permissions)
360
- implementation(libs.accompanist.drawablepainter)
361
445
362
446
implementation(libs.androidx.camera.camera2)
363
447
implementation(libs.androidx.camera.lifecycle)
@@ -393,10 +477,12 @@ androidComponents {
393
477
}
394
478
}
395
479
396
- // Disable google services for non-google variants
480
+ // Only enable google services tasks for firebase-enabled variants
397
481
androidComponents {
398
482
finalizeDsl {
399
483
tasks.named { it.contains(" GoogleServices" ) }
400
- .configureEach { enabled = name.contains(" play" , true ) }
484
+ .configureEach {
485
+ enabled = firebaseEnabledVariants.any { name.contains(it, true ) }
486
+ }
401
487
}
402
488
}
0 commit comments