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

Fix devDisabledInStaging not working with multiple productFlavors #30606

Closed
wants to merge 1 commit into from

Conversation

geraintwhite
Copy link
Contributor

@geraintwhite geraintwhite commented Dec 17, 2020

Fixes #27052

Summary

Since react-native 0.62, the devDisabledIn${buildType} syntax has stopped working for apps with multiple productFlavors. This PR adds the disableDevForVariant lambda to allow dev mode to be disabled for different variants.

Changelog

[Android] [Fixed] - Fix devDisabledIn not working with multiple productFlavors

Test Plan

I added the following log into react.gradle and ran the Android build for my app:

println("devEnabled: ${targetName}, ${devEnabled}")
# build.gradle

project.ext.react = [
    entryFile: "index.android.js",
    enableHermes: true,  // clean and rebuild if changing
    bundleInLive: true,
    disableDevForVariant: {
         def variant -> variant.name.toLowerCase().contains('release') || variant.name.toLowerCase().contains('live')
    },
]

...

flavorDimensions 'branding'
productFlavors {
    cve {
        dimension 'branding'
    }
    whce {
        dimension 'branding'
    }
}

Console output:

Reading env from: env/cve/live
devEnabled: CveDebug, true
devEnabled: CveRelease, false
devEnabled: CveLive, false
devEnabled: WhceDebug, true
devEnabled: WhceRelease, false
devEnabled: WhceLive, false

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 17, 2020
@react-native-bot react-native-bot added Bug Platform: Android Android applications. labels Dec 17, 2020
@analysis-bot
Copy link

analysis-bot commented Dec 17, 2020

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: def7dd8
Branch: main

@analysis-bot
Copy link

analysis-bot commented Jan 18, 2021

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,281,353 +0
android hermes armeabi-v7a 7,845,487 +0
android hermes x86 8,648,405 +0
android hermes x86_64 8,607,550 +0
android jsc arm64-v8a 9,798,170 +0
android jsc armeabi-v7a 8,759,118 +0
android jsc x86 9,747,085 +0
android jsc x86_64 10,347,948 +0

Base commit: def7dd8
Branch: main

@pull-bot
Copy link

PR build artifact for 75a2913 is ready.
To use, download tarball from this CircleCI job then run yarn add <path to tarball> in your React Native project.

@facebook-github-bot
Copy link
Contributor

@ShikaSD has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ShikaSD
Copy link
Contributor

ShikaSD commented Oct 14, 2021

@grit96, thanks for submitting this!
similar to #32281 (comment), do you mind updating this flag to be a lambda to configure if dev is disabled based on variant + update the gradle plugin?

@geraintwhite
Copy link
Contributor Author

@grit96, thanks for submitting this! similar to #32281 (comment), do you mind updating this flag to be a lambda to configure if dev is disabled based on variant + update the gradle plugin?

disableDevForVariant lambda added in both react.gradle and the gradle plugin.

@pull-bot
Copy link

PR build artifact for f38b56b is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@geraintwhite
Copy link
Contributor Author

@ShikaSD I noticed that the other config option that follows the devDisabledIn${targetName} pattern is bundleIn${targetName}. I'd be happy to do another PR converting that to a lambda too?

@ShikaSD
Copy link
Contributor

ShikaSD commented Oct 22, 2021

I noticed that the other config option that follows the devDisabledIn${targetName} pattern is bundleIn${targetName}. I'd be happy to do another PR converting that to a lambda too?

Sure, feel free to! :)

@facebook-github-bot
Copy link
Contributor

@ShikaSD has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

React Native Pull Requests automation moved this from Needs Triage to Closed Oct 25, 2021
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Oct 25, 2021
@facebook-github-bot
Copy link
Contributor

@ShikaSD merged this pull request in 055ea9c.

facebook-github-bot pushed a commit that referenced this pull request Oct 26, 2021
Summary:
Ref #30606 (comment)

## Changelog

[Android] [Added] - Add bundleForVariant option

Pull Request resolved: #32472

Test Plan:
I added the following log into react.gradle and ran the Android build for my app:

```
println("bundleEnabled: ${targetName}, ${bundleForVariant(variant)}")
```

```
# build.gradle

project.ext.react = [
    entryFile: "index.android.js",
    enableHermes: true,  // clean and rebuild if changing
    bundleForVariant: {
         def variant -> variant.name.toLowerCase().contains('release') || variant.name.toLowerCase().contains('live')
    },
]

...

flavorDimensions 'branding'
productFlavors {
    cve {
        dimension 'branding'
    }
    whce {
        dimension 'branding'
    }
}
```

Console output:

```
Reading env from: env/cve/live
bundleEnabled: CveDebug, false
bundleEnabled: CveRelease, true
bundleEnabled: CveLive, true
bundleEnabled: WhceDebug, false
bundleEnabled: WhceRelease, true
bundleEnabled: WhceLive, true
```

Reviewed By: cortinico, ryancat

Differential Revision: D31910406

Pulled By: ShikaSD

fbshipit-source-id: baca5efaddedddad15d974cc7bb8f3c2a4c4f35b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: Android Android applications.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

devDisabledInStaging not working with multiple productFlavors
6 participants