Uh oh!
There was an error while loading. Please reload this page.
[Android] Add support for Build Variants to react.gradle - #4686
[Android] Add support for Build Variants to react.gradle#4686AndrewJack wants to merge 1 commit into
Conversation
facebook-github-bot
commented
Dec 9, 2015
facebook-github-bot
commented
Dec 9, 2015
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
facebook-github-bot
commented
Dec 9, 2015
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
mkonicek
commented
Dec 12, 2015
What is stage alpha? |
AndrewJack
commented
Dec 14, 2015
@mkonicek it's an example of a build variant that could be used. "stage" would be the flavor and "alpha" would be the build type. The script finds all the build variants and creates bundle tasks for them, improves upon the previous hardcoded "bundleDebugJsAndAssets" and "bundleReleaseJsAndAssets" tasks |
mkonicek
commented
Dec 14, 2015
Thanks for the explanation but still need more context. Where would you use the output of bundleStageAlphaJsAndAssets and bundleBetaJsAndAssets? Would you upload them to the Play store? What's the difference between bundleDevDebugJsAndAssets and bundleDebugJsAndAssets? |
AndrewJack
commented
Dec 14, 2015
A: The output could be used for testing or uploaded to a tool such as hockey app for internal dogfooding
A: The difference here is the Gradle config. The first uses flavors and build types, and the second only uses build types. The tasks will perform the same action however the use of build variants are useful for Android developers who are dogfooding and developing an app. I have explained in greater detail below. Build types only The config would look like this: android {
buildTypes {
debug {
applicationIdSuffix ".debug"
}
alpha {
applicationIdSuffix ".alpha"
}
release {
...
}
}
}This will generate the tasks:
Flavor + Build types I may want to install the alpha app in the stage environment and install the debug app in the stage environment. I can only achieve this with this configuration. The config would look like this: android {
productFlavors {
dev {
applicationId ="com.example.dev"
}
stage {
applicationId ="com.example.stage"
}
prod {
applicationId ="com.example"
}
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
alpha {
applicationIdSuffix ".alpha"
}
release {
...
}
}
}This will generate the tasks:
|
There was a problem hiding this comment.
@mkonicek I assume you are referring to this? I could change it to something more generic like bundleIn{variantName}
There was a problem hiding this comment.
We should add a bit more info here, like explaining the properties, and may be a link on how to configure build variants,
e.g. -
// whether to bundle JS and assets in a build variant (if you have build variants configured, see <link>)// the configuration property is in the format `bundleIn${productFlavor}${buildType`// bundleInStageAlpha: true,// bundleInBeta: true,facebook-github-bot
commented
Dec 15, 2015
@AndrewJack updated the pull request. |
AndrewJack
commented
Dec 15, 2015
Updated react config comments in build.gradle |
mkonicek
commented
Dec 18, 2015
OK thanks for the explanation, get the flavors some. However, I feel like this adds a lot of complexity into the template and the code will have to be maintained. Not everyone might necessarily need these features - no one has been asking about these so far. Do you think it would make more sense to publish this as a blogpost somewhere and people can easily add it to their build files if needed? |
satya164
commented
Dec 18, 2015
@mkonicek Even if we don't want to merge the build flavours features to the core, I like how the file has been refactored to remove duplicate code. For example the |
AndrewJack
commented
Dec 18, 2015
Ok, that makes sense, but I agree with @satya164. |
AndrewJack
commented
Dec 18, 2015
Maybe a separate React Native Gradle plugin would be useful? That would keep the template simple but allow the plugin to be improved separately. |
facebook-github-bot
commented
Jan 3, 2016
@AndrewJack updated the pull request. |
mkonicek
commented
Jan 6, 2016
OK I played around with Gradle variants today and finally understand variants and flavors somewhat. I like how this removes code duplication, keeps the existing behavior and adds extensibility. @foghina Are you happy with this being merged? |
There was a problem hiding this comment.
Here's a shorter URL: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
mkonicek
commented
Jan 6, 2016
Slightly related PR here: #5160 |
AndrewJack
commented
Jan 7, 2016
I will make the requested changes today. |
There was a problem hiding this comment.
nit: uppercase S, lowercase A ("bundle JS and...")
foghina
commented
Jan 7, 2016
This is pretty amazing, sorry for taking a long time to review. Thanks for the PR! We should merge #5160 today so you can rebase on top of that and get this merged as well. |
facebook-github-bot
commented
Jan 7, 2016
@AndrewJack updated the pull request. |
1 similar comment
facebook-github-bot
commented
Jan 7, 2016
@AndrewJack updated the pull request. |
facebook-github-bot
commented
Jan 7, 2016
@AndrewJack updated the pull request. |
mkonicek
commented
Jan 7, 2016
Thanks for rebasing this so quickly! I see you're making updates, let me know when we should merge :) |
facebook-github-bot
commented
Jan 7, 2016
@AndrewJack updated the pull request. |
1 similar comment
facebook-github-bot
commented
Jan 7, 2016
@AndrewJack updated the pull request. |
AndrewJack
commented
Jan 7, 2016
@mkonicek All done, just had to test it. |
There was a problem hiding this comment.
Shouldn't --dev be false in release build?
There was a problem hiding this comment.
How to we want to handle this?
- Another config value
- if release then --dev false
There was a problem hiding this comment.
I think if release then dev false is sensible.
There was a problem hiding this comment.
combination of both isn't too hard
There was a problem hiding this comment.
@AndrewJack dunno. can't think of a scenario where someone will want production build to have dev warnings. Also if someone does, he can always manually change it.
There was a problem hiding this comment.
@satya164 I would use it for a tester build, to get more logs out of a build.
Its easy to add if someone needs it, so I will just add the "if release option".
facebook-github-bot
commented
Jan 8, 2016
@AndrewJack updated the pull request. |
There was a problem hiding this comment.
dev mode can be made configurable like this:
def devEnabled = config."devMode${targetName}"?:!targetName.toLowerCase().contains("release")foghina
commented
Jan 8, 2016
Sick PR! @facebook-github-bot shipit |
facebook-github-bot
commented
Jan 8, 2016
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1655573684725605/int_phab to review. |
Summary: This PR adds support for Android Gradle [Build Variants](https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide#TOC-Build-Variants) when generating the JS bundle. **Before**: only supported "bundleDebugJsAndAssets" and "bundleReleaseJsAndAssets" **Now**: all variants are supported Examples: "bundleDevDebugJsAndAssets", "bundleStageAlphaJsAndAssets", or "bundleBetaJsAndAssets" The Gradle script will automatically create bundle tasks for each build variant found in a project. Closesreact/react-native#4686 Reviewed By: svcscm Differential Revision: D2815856 Pulled By: foghina fb-gh-sync-id: 4518de70d178205bc3e5044d2446b56c40298da2
This PR adds support for Android Gradle Build Variants when generating the JS bundle.
Before: only supported "bundleDebugJsAndAssets" and "bundleReleaseJsAndAssets"
Now: all variants are supported
Examples: "bundleDevDebugJsAndAssets", "bundleStageAlphaJsAndAssets", or "bundleBetaJsAndAssets"
The Gradle script will automatically create bundle tasks for each build variant found in a project.