Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: solve foss source sets and dependencies statically 🍒 #3083

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ 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

private fun getFlavorsSettings(): NormalizedFlavorSettings =
try {
Expand All @@ -76,21 +74,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")
}
}
}
}
Expand Down Expand Up @@ -193,15 +187,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)

Expand Down
Loading