Created
July 20, 2021 23:19
-
-
Save radityagumay/83eadf484f787a69e8658a52cb9e4d56 to your computer and use it in GitHub Desktop.
Delete certain proguard rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```groovy | |
afterEvaluate { | |
// All proguard tasks shall depend on our filter task | |
def proguardTasks = tasks.findAll { task -> | |
task.name.startsWith('transformClassesAndResourcesWithProguardFor') } | |
proguardTasks.each { task -> task.dependsOn filterConsumerRules } | |
} | |
// Let define our custom task that filters some unwanted | |
// consumer proguard rules | |
task(filterConsumerRules) << { | |
// Collect all consumer rules first | |
FileTree allConsumerRules = fileTree(dir: 'build/intermediates/exploded-aar', include: '**/proguard.txt') | |
// Now filter the ones we want to exclude: | |
// Change it to fit your needs, replace library with | |
// the name of the aar you want to filter. | |
FileTree excludeRules = allConsumerRules.matching { | |
include '**/library/**' | |
} | |
// Print some info and delete the file, so ProGuard | |
// does not pick it up. We could also just rename it. | |
excludeRules.each { File file -> | |
println 'Deleting ProGuard consumer rule ' + file | |
file.delete() | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment