Skip to content

Commit 1cf605d

Browse files
jaggs6facebook-github-bot-3
authored andcommitted
Fix Product Flavour builds
Summary: - Capitalise productFlavorName for target path - Capitalise buildType in sourceName when flavour exists - Fix the path the assets are added. - Backward compatibility with bundleIn(buildTypeName) when flavours are added Closes react#5580 Reviewed By: svcscm Differential Revision: D2911735 Pulled By: mkonicek fb-gh-sync-id: 6fb391a12ee27ee2a503961d8779a85d31cf5367
1 parent fca1865 commit 1cf605d

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

local-cli/generator-android/templates/src/app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import com.android.build.OutputFile
2626
*
2727
* // whether to bundle JS and assets in another build variant (if configured).
2828
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29-
* // The configuration property is in the format 'bundleIn${productFlavor}${buildType}'
29+
* // The configuration property can be in the following formats
30+
* // 'bundleIn${productFlavor}${buildType}'
31+
* // 'bundleIn${buildType}'
3032
* // bundleInFreeDebug: true,
3133
* // bundleInPaidRelease: true,
3234
* // bundleInBeta: true,

local-cli/generator-android/templates/src/app/react.gradle

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,20 @@ gradle.projectsEvaluated {
3030

3131
productFlavors.each { productFlavorName ->
3232
buildTypes.each { buildTypeName ->
33-
// Create variant and source names
34-
def sourceName = "${buildTypeName}"
35-
def targetName = "${sourceName.capitalize()}"
36-
if (productFlavorName) {
37-
sourceName = "${productFlavorName}${targetName}"
38-
}
33+
// Create variant and target names
34+
def targetName = "${productFlavorName.capitalize()}${buildTypeName.capitalize()}"
35+
def targetPath = productFlavorName ?
36+
"${productFlavorName}/${buildTypeName}" :
37+
"${buildTypeName}"
3938

4039
// React js bundle directories
4140
def jsBundleDirConfigName = "jsBundleDir${targetName}"
4241
def jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ?:
43-
file("$buildDir/intermediates/assets/${sourceName}")
42+
file("$buildDir/intermediates/assets/${targetPath}")
4443

4544
def resourcesDirConfigName = "jsBundleDir${targetName}"
4645
def resourcesDir = elvisFile(config."${resourcesDirConfigName}") ?:
47-
file("$buildDir/intermediates/res/merged/${sourceName}")
46+
file("$buildDir/intermediates/res/merged/${targetPath}")
4847
def jsBundleFile = file("$jsBundleDir/$bundleAssetName")
4948

5049
// Bundle task name for variant
@@ -80,7 +79,9 @@ gradle.projectsEvaluated {
8079
"--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
8180
}
8281

83-
enabled config."bundleIn${targetName}" ?: targetName.toLowerCase().contains("release")
82+
enabled config."bundleIn${targetName}" ||
83+
config."bundleIn${buildTypeName.capitalize()}" ?:
84+
targetName.toLowerCase().contains("release")
8485
}
8586

8687
// Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process

0 commit comments

Comments
 (0)