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 enableBugsnag to work with multiple configs #22

Merged
merged 1 commit into from
May 18, 2016

Conversation

tmelz
Copy link
Contributor

@tmelz tmelz commented May 17, 2016

#21 is functional, but doesn't work for cases like:

productFlavors {
    dev {
        project.bugsnag { enableBugsnag false }
    }
    prod {
        project.bugsnag { enableBugsnag true }
    }
}

because all of the project.bugsnag statements are evaluated at configuration time--only the most recent one will "stick". I'd previously mistaken this as a closure that was only evaluated at runtime--whoops.

It looks like the easiest solution for this is to make use of Groovy's extra properties; we can store the enableBugsnag value either on the ProductFlavor itself or on the BuildType:

productFlavors {
    prod {}
    dev { ext.enableBugsnag = false }
}
buildTypes {
    debug { ext.enableBugsnag = false }
    release {}
}

Then the values won't override each other and we can fetch them when we're applying the plugin to the variant. It looks like this is what Fabric is doing for Crashlytics.


Testing:

buildTypes {
    debug { ext.enableBugsnag = false }
    release {}
}

➜  TestApplication gw assembleDebug | grep Bugsnag
➜  TestApplication gw assembleRelease | grep Bugsnag
:app:processBugsnagReleaseManifest
:app:processBugsnagReleaseProguard
:app:uploadBugsnagReleaseMapping
productFlavors {
    prod {}
    dev { ext.enableBugsnag = false }
}
buildTypes {
    debug {}
    release {}
}

➜  TestApplication gw assembleDevDebug | grep Bugsnag
➜  TestApplication gw assembleProdDebug | grep Bugsnag
:app:processBugsnagProdDebugManifest
:app:processBugsnagProdDebugProguard
:app:uploadBugsnagProdDebugMapping
➜  TestApplication gw assembleDevRelease | grep Bugsnag
➜  TestApplication gw assembleProdRelease | grep Bugsnag
:app:processBugsnagProdReleaseManifest
:app:processBugsnagProdReleaseProguard
:app:uploadBugsnagProdReleaseMapping
productFlavors {
    prod {}
    dev { ext.enableBugsnag = false }
}
buildTypes {
    debug { ext.enableBugsnag = false }
    release {}
}

➜  TestApplication gw assembleDevDebug | grep Bugsnag
➜  TestApplication gw assembleDevDebug | grep Bugsnag
➜  TestApplication gw assembleProdDebug | grep Bugsnag
➜  TestApplication gw assembleDevRelease | grep Bugsnag
➜  TestApplication gw assembleProdRelease | grep Bugsnag
:app:processBugsnagProdReleaseManifest
:app:processBugsnagProdReleaseProguard
:app:uploadBugsnagProdReleaseMapping

@loopj
Copy link
Contributor

loopj commented May 18, 2016

Thanks again @tmelz! This definitely makes more sense and offers more granular control.

@loopj loopj merged commit 9d18210 into bugsnag:master May 18, 2016
@loopj
Copy link
Contributor

loopj commented May 18, 2016

@tmelz published as v2.1.1 - thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants