Skip to content

Commit

Permalink
fix: error in deciding whether the current build should use open sour…
Browse files Browse the repository at this point in the history
…ce only dependencies or not (#2890)
  • Loading branch information
MohamadJaara authored Apr 15, 2024
1 parent 480a5a6 commit fb657e9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
19 changes: 14 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import scripts.Variants_gradle

/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
Expand Down Expand Up @@ -42,6 +44,11 @@ repositories {
google()
}

fun isFossSourceSet(): Boolean {
return (Variants_gradle.Default.explicitBuildFlavor() ?: gradle.startParameter.taskRequests.toString())
.lowercase()
.contains("fdroid")
}
android {
// Most of the configuration is done in the build-logic
// through the Wire Application convention plugin
Expand All @@ -57,16 +64,17 @@ android {
}
android.buildFeatures.buildConfig = true

var fdroidBuild = gradle.startParameter.taskRequests.toString().lowercase().contains("fdroid")
val fdroidBuild = isFossSourceSet()

sourceSets {
// Add the "foss" sourceSets for the fdroid flavor
if(fdroidBuild) {
if (fdroidBuild) {
getByName("fdroid") {
java.srcDirs("src/foss/kotlin", "src/prod/kotlin")
res.srcDirs("src/prod/res")
println("Building with FOSS sourceSets")
}
// For all other flavors use the "nonfree" sourceSets
// For all other flavors use the "nonfree" sourceSets
} else {
getByName("main") {
java.srcDirs("src/nonfree/kotlin")
Expand Down Expand Up @@ -162,8 +170,9 @@ dependencies {
implementation(libs.bundlizer.core)

// firebase
var fdroidBuild = gradle.startParameter.taskRequests.toString().lowercase().contains("fdroid")
if (!fdroidBuild) {
var fdroidBuild = isFossSourceSet()

if (!fdroidBuild) {
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.fcm)
implementation(libs.googleGms.location)
Expand Down
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ buildscript {
}
dependencies {
classpath(libs.hilt.gradlePlugin)
var fdroidBuild = gradle.startParameter.taskRequests.toString().lowercase().contains("fdroid")
val fdroidBuild = (System.getenv("flavor")
?: System.getenv("FLAVOR")
?: gradle.startParameter.taskRequests.toString())
.lowercase()
.contains("fdroid")

if (fdroidBuild) {
println("Not including gms")
} else {
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/scripts/infrastructure.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tasks.register("runUnitTests") {

tasks.register("runAcceptanceTests") {
description = "Runs all Acceptance Tests in the connected device."
dependsOn(":app:connected${Default.BUILD_FLAVOR.capitalize()}DebugAndroidTest")
dependsOn(":app:connected${Default.resolvedBuildFlavor().capitalize()}DebugAndroidTest")
}

tasks.register("assembleApp") {
Expand Down Expand Up @@ -71,7 +71,7 @@ tasks.register("runApp", Exec::class) {
val sdkDir = properties["sdk.dir"]
val adb = "${sdkDir}/platform-tools/adb"

val applicationPackage = "com.wire.android.${Default.BUILD_FLAVOR}"
val applicationPackage = "com.wire.android.${Default.resolvedBuildFlavor()}"
val launchActivity = "com.wire.android.feature.launch.ui.LauncherActivity"

commandLine(adb, "shell", "am", "start", "-n", "${applicationPackage}/${launchActivity}")
Expand Down
13 changes: 10 additions & 3 deletions buildSrc/src/main/kotlin/scripts/variants.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ object BuildTypes {
}

object Default {
val BUILD_FLAVOR: String = System.getenv("flavor") ?: System.getenv("FLAVOR") ?: ProductFlavors.Dev.buildName
val BUILD_TYPE = System.getenv("buildType") ?: System.getenv("BUILD_TYPE") ?: BuildTypes.DEBUG
fun explicitBuildFlavor(): String? = System.getenv("flavor")
?: System.getenv("FLAVOR")

val BUILD_VARIANT = "${BUILD_FLAVOR.capitalize()}${BUILD_TYPE.capitalize()}"
fun resolvedBuildFlavor(): String = explicitBuildFlavor() ?: ProductFlavors.Dev.buildName

fun explicitBuildType(): String? = System.getenv("buildType")
?: System.getenv("BUILD_TYPE")

fun resolvedBuildType(): String = explicitBuildType() ?: BuildTypes.DEBUG

val BUILD_VARIANT = "${resolvedBuildFlavor().capitalize()}${resolvedBuildType().capitalize()}"
}

fun NamedDomainObjectContainer<ApplicationProductFlavor>.createAppFlavour(
Expand Down

0 comments on commit fb657e9

Please sign in to comment.