diff --git a/app/build.gradle.kts b/app/build.gradle.kts index bae74e567ec..e014018aea5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -44,11 +44,10 @@ repositories { google() } -fun isFossSourceSet(): Boolean { - return (Variants_gradle.Default.explicitBuildFlavor() ?: gradle.startParameter.taskRequests.toString()) - .lowercase() - .contains("fdroid") -} +val nonFreeFlavors = setOf("prod", "internal", "staging", "beta", "dev") +val fossFlavors = setOf("fdroid") +val allFlavors = nonFreeFlavors + fossFlavors + android { // Most of the configuration is done in the build-logic // through the Wire Application convention plugin @@ -64,21 +63,17 @@ android { } android.buildFeatures.buildConfig = true - val fdroidBuild = isFossSourceSet() - sourceSets { - // Add the "foss" sourceSets for the fdroid flavor - 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 - } else { - getByName("main") { - java.srcDirs("src/nonfree/kotlin") - println("Building with non-free sourceSets") + allFlavors.forEach { flavor -> + getByName(flavor) { + if (flavor in fossFlavors) { + java.srcDirs("src/foss/kotlin", "src/prod/kotlin") + res.srcDirs("src/prod/res") + println("Adding FOSS sourceSets to '$flavor' flavor") + } else { + java.srcDirs("src/nonfree/kotlin") + println("Adding non-free sourceSets to '$flavor' flavor") + } } } } @@ -181,15 +176,15 @@ dependencies { implementation(libs.resaca.hilt) implementation(libs.bundlizer.core) - var fdroidBuild = isFossSourceSet() - - if (!fdroidBuild) { - // firebase - implementation(platform(libs.firebase.bom)) - implementation(libs.firebase.fcm) - implementation(libs.googleGms.location) - } else { - println("Excluding FireBase for FDroid build") + allFlavors.forEach { flavor -> + if (flavor in nonFreeFlavors) { + println("Adding nonfree libraries to '$flavor' flavor") + add("${flavor}Implementation", platform(libs.firebase.bom)) + add("${flavor}Implementation", libs.firebase.fcm) + add("${flavor}Implementation", libs.googleGms.location) + } else { + println("Skipping nonfree libraries for '$flavor' flavor") + } } implementation(libs.androidx.work)