Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Fix disableVersionCheck when GoogleServicesPlugin is applied with afterEvaluate #147

Merged
merged 4 commits into from
Dec 12, 2020

Conversation

jkasten2
Copy link
Member

@jkasten2 jkasten2 commented Dec 7, 2020

Issue

  • disableGMSVersionChecks doesn't work in a case which this PR addresses.
    afterEvaluate {
        rootProject.subprojects {
            if (name == "app") {
                if (!plugins.hasPlugin('com.google.gms.google-services')) {
                    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
                }
            }
        }
    }

Fixes

Reviewing

Recommend reviewing commit by commit

@jkasten2 jkasten2 added the WIP label Dec 7, 2020
@jkasten2 jkasten2 force-pushed the upgrade/apg_4.1.1_and_gradle_6.7.1 branch from fe5ae07 to f66dd37 Compare December 7, 2020 19:19
Base automatically changed from upgrade/apg_4.1.1_and_gradle_6.7.1 to master December 7, 2020 19:21
@jkasten2 jkasten2 changed the title WIP - Fix/disable gms version checks WIP - Fix Disable gms version checks Dec 8, 2020
* This covers the disableVersionCheck feature we never had test coverage on before.
* Adding a failing test where our disableVersionCheck does not work if the google-services gradle plugin was added with afterEvaluate
* The issue was there is a race condition with the project's `afterEvaluate` and this plugin.
The order operations was a follows:
1. This plugin's afterEvaluate fires
2. `googleServices` is not found
3. Project's afterEvaluate fires
4. Project run's apply plugin: 'com.google.gms.google-services'
5. We never set `disableVersionCheck = true`

* To fix the issue switched to `project.plugins.withType(Plugin)` which fires as soon as a plugin is applied, no matter how / when it was.
@jkasten2 jkasten2 changed the title WIP - Fix Disable gms version checks Fix disableVersionCheck when GoogleServicesPlugin is applied with afterEvaluate Dec 12, 2020
@jkasten2 jkasten2 removed the WIP label Dec 12, 2020
@jkasten2
Copy link
Member Author

✔️ Test passed "Travis CI - Pull Request Successful in 10m — Build Passed"

Ignore failed "Travis CI - Branch Cancelled after 5m — Build Canceled" as I did cancel it on purpose as tests were running twice.

@jkasten2 jkasten2 merged commit eb1513b into master Dec 12, 2020
@jkasten2 jkasten2 deleted the fix/disableGMSVersionChecks branch December 12, 2020 04:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants