|
| 1 | +# Proguard Plugin |
| 2 | + |
| 3 | +A Gradle plugin that uploads ProGuard/R8 obfuscation mapping files to the [Faststats](https://faststats.dev) sourcemaps |
| 4 | +API for stacktrace deobfuscation. |
| 5 | + |
| 6 | +## Installation |
| 7 | + |
| 8 | +Add the plugin to your project's `build.gradle.kts`: |
| 9 | + |
| 10 | +```kotlin |
| 11 | +plugins { |
| 12 | + id("dev.faststats.proguard-mappings-upload") version "0.1.0" |
| 13 | +} |
| 14 | +``` |
| 15 | + |
| 16 | +Or in Groovy (`build.gradle`): |
| 17 | + |
| 18 | +```groovy |
| 19 | +plugins { |
| 20 | + id 'dev.faststats.proguard-mappings-upload' version '0.1.0' |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +## Configuration |
| 25 | + |
| 26 | +### With a custom ProGuard task |
| 27 | + |
| 28 | +```kotlin |
| 29 | +mappingsUpload { |
| 30 | + authToken.set("your-auth-token") |
| 31 | + proguardTask.set(tasks.getByName("proguard")) |
| 32 | + mappingFiles.from(layout.buildDirectory.file("proguard/mapping.txt")) |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +Setting `proguardTask` ensures the upload task runs after ProGuard finishes. You still need to point `mappingFiles` to |
| 37 | +the actual mapping file location (matching your `printmapping` config). |
| 38 | + |
| 39 | +### Android Projects |
| 40 | + |
| 41 | +```kotlin |
| 42 | +mappingsUpload { |
| 43 | + authToken.set("your-auth-token") |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +The plugin automatically detects Android R8/ProGuard mapping file outputs when the Android Gradle Plugin is present. No |
| 48 | +additional configuration is needed. |
| 49 | + |
| 50 | +### All Options |
| 51 | + |
| 52 | +```kotlin |
| 53 | +mappingsUpload { |
| 54 | + // Required – API auth token. Falls back to FASTSTATS_AUTH_TOKEN env var. |
| 55 | + authToken.set("your-auth-token") |
| 56 | + |
| 57 | + // Optional – API endpoint (default: https://sourcemaps.faststats.dev/api/sourcemaps) |
| 58 | + endpoint.set("https://sourcemaps.faststats.dev/api/sourcemaps") |
| 59 | + |
| 60 | + // Optional – Build identifier (default: project.version) |
| 61 | + buildId.set("1.2.3") |
| 62 | + |
| 63 | + // Optional – Task that produces the mapping file (adds a dependsOn) |
| 64 | + proguardTask.set(tasks.getByName("proguard")) |
| 65 | + |
| 66 | + // Optional – Mapping files to upload (default: build/obfuscation-mappings.txt) |
| 67 | + mappingFiles.from(layout.buildDirectory.file("proguard/mapping.txt")) |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +## Usage |
| 72 | + |
| 73 | +Run the upload task: |
| 74 | + |
| 75 | +```bash |
| 76 | +./gradlew uploadProguardMappings |
| 77 | +``` |
| 78 | + |
| 79 | +Or chain it after your obfuscation task: |
| 80 | + |
| 81 | +```bash |
| 82 | +./gradlew proguard uploadProguardMappings |
| 83 | +``` |
| 84 | + |
| 85 | +## CI Configuration |
| 86 | + |
| 87 | +### GitHub Actions |
| 88 | + |
| 89 | +```yaml |
| 90 | +name: Build & Upload Mappings |
| 91 | + |
| 92 | +on: |
| 93 | + push: |
| 94 | + branches: [ main ] |
| 95 | + |
| 96 | +jobs: |
| 97 | + build: |
| 98 | + runs-on: ubuntu-latest |
| 99 | + steps: |
| 100 | + - uses: actions/checkout@v4 |
| 101 | + |
| 102 | + - uses: actions/setup-java@v4 |
| 103 | + with: |
| 104 | + distribution: temurin |
| 105 | + java-version: 17 |
| 106 | + |
| 107 | + - name: Build & Upload |
| 108 | + run: ./gradlew proguard uploadProguardMappings |
| 109 | + env: |
| 110 | + FASTSTATS_AUTH_TOKEN: ${{ secrets.FASTSTATS_AUTH_TOKEN }} |
| 111 | +``` |
| 112 | +
|
| 113 | +### GitLab CI |
| 114 | +
|
| 115 | +```yaml |
| 116 | +build: |
| 117 | + stage: build |
| 118 | + script: |
| 119 | + - ./gradlew proguard uploadProguardMappings |
| 120 | + variables: |
| 121 | + FASTSTATS_AUTH_TOKEN: $FASTSTATS_AUTH_TOKEN |
| 122 | +``` |
| 123 | +
|
| 124 | +## How It Works |
| 125 | +
|
| 126 | +1. The plugin looks for mapping files added via `mappingFiles.from(...)`, or auto-detected Android build outputs. |
| 127 | +2. If `proguardTask` is set, the upload task automatically depends on it. |
| 128 | +3. Uses `project.version` as the `buildId` by default. |
| 129 | +4. Each mapping file is split by class sections and uploaded in batches of up to 50MB, ensuring no class mapping is |
| 130 | + split across batches. |
| 131 | + |
| 132 | +## Requirements |
| 133 | + |
| 134 | +- Gradle 7.0+ |
| 135 | +- JDK 11+ |
0 commit comments