Skip to content

A Gradle plugin that generated UUIDs, add it to your AndroidManifest.xml and uploads the UUID together with the generated mapping file to Sentry.

License

Notifications You must be signed in to change notification settings

bhavishyaone/SentryProguardGradlePlugin

 
 

Repository files navigation

🎉 SentryProguardGradlePlugin

CI Maven Central Snapshot MIT

🚀 A Gradle plugin that generates UUIDs, adds them to your AndroidManifest.xml, and uploads the UUID along with the generated mapping file to Sentry.

📚 Table of Contents

🔧 Usage

🔌 Apply the plugin

Add the plugin to your Android application build.gradle[.kts] file and configure it:

plugins {
    id "com.ioki.sentry.proguard" version "[CURRENT_VERSION]"
}

sentryProguard {
    organization.set("SENTRY_ORG")
    project.set("SENTRY_PROJECT")
    authToken.set("SENTRY_AUTH_TOKEN")
    noUpload.set(false)
}

The sentryProguard.noUpload function is useful for development purposes. Normally, you don"t want to upload the mapping file to Sentry while creating a minified version on developer machines. Instead, you just want to upload the mapping file on your CI during a "real release." You can implement it like this:

def sentryUpload = hasProperty("SENTRY_UPLOAD")
sentryProguard {
    noUpload.set(!sentryUpload)
}

By default, if you don’t set the Gradle property, the plugin won’t upload the mapping files. On your CI, however, you set the property, and therefore the mapping file will be uploaded.

🔍 How it works under the hood

When you run "any" task on a minifiedEnabled build type, the Plugin will:

  • Generate a UUID 📦
  • Place a <meta-data> attribute in the AndroidManifest.xml (see also this sentry-android-gradle-plugin code)
  • Create a task to download the Sentry CLI 💻
  • Create a task for each build variant that uploads the UUID along with the mapping file via the Sentry CLI
  • Hook the created tasks into the task graph (adds a finalizedBy(uploadUuidTask) to the minify[BuildVariant]WithR8 task)

🧪 Testing

To run the tests, you either have to provide the ANDROID_HOME environment variable (pointing to the Android SDK path) or add a local.properties file to the androidTestProject:

// on macOS mostly at: ~/Library/Android/sdk
sdk.dir=[path/to/the/android/sdk]

🚀 Release

🌟 Snapshot release

By default, each merge to the main branch will create a new SNAPSHOT release. If you want to use the latest and greatest, use the SNAPSHOT version of the plugin. Please be aware that they might contain bugs or behavior changes.

To use the SNAPSHOT version, include the Sonatype snapshot repository in your settings.gradle[.kts]:

pluginManagement {
    repositories {
        maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots/")
    }
}

✅ Proper release

  1. Checkout the main branch
  2. Update the version in build.gradle.kts
  3. Update the version for the consuming of plugin marker publication via mavenLocal works test
  4. Commit
    • git commit -m "Prepare next release"
  5. Tag the version with the same version and push it to origin
    • git tag [VERSION]
    • git push origin [VERSION]
  6. Update the version to the "next minor version" (including -SNAPSHOT)
  7. Update the version for the consuming of plugin marker publication via mavenLocal works test
  8. Commit and push
  9. Create a new GitHub release

About

A Gradle plugin that generated UUIDs, add it to your AndroidManifest.xml and uploads the UUID together with the generated mapping file to Sentry.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 100.0%