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

Specify consumer Proguard files #345

Merged
merged 2 commits into from
Jul 6, 2018
Merged

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Jul 4, 2018

Goal

Adds ProGuard keep rules to the AAR artefact. This means that the library will work correctly when minification is enabled, without relying on the bugsnag gradle plugin to edit the library's proguard files.

Design

This allows users to avoid using the bugsnag gradle plugin if they so wish, without any additional configuration of ProGuard on their part.

Changeset

Added a proguard file with keep rules for the relevant classes.

Tests

Used Android Studio's APK analyzer to verify that an example project without the gradle plugin applied retained the correct classes in its Dex file.

Discussion

  • We may want to consider the task in our gradle plugin which adds these rules automatically. The risk of this is that it could break builds for anyone who doesn't
    read the release notes.
  • Do we need to update the Docs? They seemed ok to me.

Review

For the submitter, initial self-review:

  • Commented on code changes inline explain the reasoning behind the approach
  • Reviewed the test cases added for completeness and possible points for discussion
  • A changelog entry was added for the goal of this pull request
  • Check the scope of the changeset - is everything in the diff required for the pull request?
  • This pull request is ready for:
    • Initial review of the intended approach, not yet feature complete
    • Structural review of the classes, functions, and properties modified
    • Final review

For the pull request reviewer(s), this changeset has been reviewed for:

  • Consistency across platforms for structures or concepts added or modified
  • Consistency between the changeset and the goal stated above
  • Internal consistency with the rest of the library - is there any overlap between existing interfaces and any which have been added?
  • Usage friction - is the proposed change in usage cumbersome or complicated?
  • Performance and complexity - are there any cases of unexpected O(n^3) when iterating, recursing, flat mapping, etc?
  • Concurrency concerns - if components are accessed asynchronously, what issues will arise
  • Thoroughness of added tests and any missing edge cases
  • Idiomatic use of the language

Specifies the classes in this library which should be kept if ProGuard is enabled. See
https://developer.android.com/studio/projects/android-library
@fractalwrench fractalwrench requested a review from a team July 4, 2018 12:46
@coveralls
Copy link

coveralls commented Jul 4, 2018

Coverage Status

Coverage remained the same at 74.791% when pulling 79a8461 on proguard-consumer-files into 944da8d on next.

@kattrali
Copy link
Contributor

kattrali commented Jul 5, 2018

We may want to consider the task in our gradle plugin which adds these rules automatically. The risk of this is that it could break builds for anyone who doesn't
read the release notes.

What can we do to make this transition smoother? Can the Gradle plugin be changed to conditionally add the Bugsnag rules (based on the version of bugsnag-android in use or something)?

Do we need to update the Docs? They seemed ok to me.

Seems ok here too.

@fractalwrench
Copy link
Contributor Author

What can we do to make this transition smoother? Can the Gradle plugin be changed to conditionally add the Bugsnag rules (based on the version of bugsnag-android in use or something)?

It should be possible to check the dependency at runtime within the gradle plugin, using something along the following lines:

    project.configurations.forEach { conf ->
        conf.allDependencies.forEach { dep ->
            if (dep.group == "com.bugsnag" && dep.name == "bugsnag-android") {
                println("Dep: " + dep)
            }
        }
    }

If it makes sense we could grab the lowest version from the dependencySet (after de-duping etc), and only write to the ProGuard file if the version is less than 4.X.X.

@kattrali
Copy link
Contributor

kattrali commented Jul 5, 2018

Sounds good to me 🤔

@fractalwrench
Copy link
Contributor Author

@fractalwrench fractalwrench merged commit a3d8650 into next Jul 6, 2018
@fractalwrench fractalwrench deleted the proguard-consumer-files branch July 6, 2018 11:20
lemnik pushed a commit that referenced this pull request Jun 2, 2021
Tweak error message for missing source-map tool
rich-bugsnag pushed a commit that referenced this pull request Sep 3, 2021
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.

3 participants