From cd4545f812d0c1404dcc9ce2982babd009f188f9 Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Wed, 5 Apr 2017 12:44:00 -0700 Subject: [PATCH] configurable devEnabled in React.gradle Summary: This PR adds support for configurable devEnabled option when building an android app. This is currently hardcoded. The reason for making this configurable is this: I have an app that uses code-push and 3 buildConfigs. I want to have a debugging version which has `devEnabled = true`, then a staging version which has `devEnabled = false` (this version of the app is used internally for testing and should behave just like a release version of the app, and when the tests succeed the changes are promoted into the release version to the users out there, using code-push). The last version is a standard release version with `devEnabled = false`. Currently, `devEnabled` is hardwired like this: `!targetName.toLowerCase().contains("release")` so by default my `staging` buildConfig will have `devEnabled = true` but I'd like it to be false. With this PR it'd be possible to configure this as follows, while not breaking the current behavior. `'devDisabledIn${productFlavor}${buildType}'` `'devDisabledIn${buildType Closes https://github.com/facebook/react-native/pull/11438 Differential Revision: D4630513 Pulled By: hramos fbshipit-source-id: b6817cf4c144fc948f76785e9cb5f93a13a6a6a2 --- local-cli/templates/HelloWorld/android/app/build.gradle | 7 +++++++ react.gradle | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/local-cli/templates/HelloWorld/android/app/build.gradle b/local-cli/templates/HelloWorld/android/app/build.gradle index 5a6bc9bafa9..c46fd943932 100644 --- a/local-cli/templates/HelloWorld/android/app/build.gradle +++ b/local-cli/templates/HelloWorld/android/app/build.gradle @@ -33,6 +33,13 @@ import com.android.build.OutputFile * // bundleInPaidRelease: true, * // bundleInBeta: true, * + * // whether to disable dev mode in custom build variants (by default only disabled in release) + * // for example: to disable dev mode in the staging build type (if configured) + * devDisabledInStaging: true, + * // The configuration property can be in the following formats + * // 'devDisabledIn${productFlavor}${buildType}' + * // 'devDisabledIn${buildType}' + * * // the root of your project, i.e. where "package.json" lives * root: "../../", * diff --git a/react.gradle b/react.gradle index 09c06ca7e54..16c58c2aca7 100644 --- a/react.gradle +++ b/react.gradle @@ -76,7 +76,8 @@ gradle.projectsEvaluated { workingDir reactRoot // Set up dev mode - def devEnabled = !targetName.toLowerCase().contains("release") + def devEnabled = !(config."devDisabledIn${targetName}" + || targetName.toLowerCase().contains("release")) if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine("cmd", "/c", *nodeExecutableAndArgs, "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}", "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, *extraPackagerArgs)