-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support resource customization (#1739)
- Loading branch information
1 parent
7251e4c
commit a51895b
Showing
7 changed files
with
112 additions
and
45 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...customization/NormalizedFlavorSettings.kt → ...n/customization/BuildTimeConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
buildSrc/src/main/kotlin/customization/ResourcesOverrider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package customization | ||
|
||
import com.android.build.gradle.BaseExtension | ||
import com.android.build.gradle.internal.api.DefaultAndroidSourceDirectorySet | ||
import flavor.ProductFlavors | ||
import java.io.File | ||
|
||
fun BaseExtension.overrideResourcesForAllFlavors( | ||
customResourcesRootDir: File | ||
) { | ||
|
||
sourceSets { | ||
ProductFlavors.all.forEach { | ||
getByName(it.buildName).apply { | ||
val resDir = (res as DefaultAndroidSourceDirectorySet).srcDirs.first() | ||
println("Copying files from '${customResourcesRootDir.absolutePath}' into '${resDir.absolutePath}'") | ||
|
||
customResourcesRootDir.walkTopDown().filter { !it.isDirectory }.forEach { customContent -> | ||
val relativePath = customContent.relativeTo(customResourcesRootDir).path | ||
val targetFile = File(resDir, relativePath) | ||
customContent.copyTo(targetFile, overwrite = true) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package flavor | ||
|
||
object FlavorDimensions { | ||
const val DEFAULT = "default" | ||
} | ||
|
||
sealed class ProductFlavors( | ||
val buildName: String, | ||
val appName: String, | ||
val dimensions: String = FlavorDimensions.DEFAULT, | ||
val shareduserId: String = "" | ||
) { | ||
override fun toString(): String = this.buildName | ||
|
||
object Dev : ProductFlavors("dev", "Wire Dev") | ||
object Staging : ProductFlavors("staging", "Wire Staging") | ||
|
||
object Beta : ProductFlavors("beta", "Wire Beta") | ||
object Internal : ProductFlavors("internal", "Wire Internal") | ||
object Production : ProductFlavors("prod", "Wire", shareduserId = "com.waz.userid") | ||
|
||
companion object { | ||
val all: Collection<ProductFlavors> = setOf( | ||
Dev, | ||
Staging, | ||
Beta, | ||
Internal, | ||
Production, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters