mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 08:15:02 +00:00
Fix warning about deprecated Gradle keepRules.file API (#7498)
* Fix warning about deprecated `keepRules.file` API The proguard files have been moved to `app/proguard` in several directories for `common`, `foss`, and `enterprise` rules and it's those directories that are added through `keepRules.addStaticSourceDirectory(dir)`. * Use `findPropery` instead of the deprecated `project.properties["key"]` API for `allWarningsAsErrors` * Remove very legacy .gitignore rule and restore proguard `.keep` rules
This commit is contained in:
committed by
GitHub
parent
1300112edc
commit
feef42db5a
+28
-17
@@ -127,24 +127,11 @@ android {
|
||||
optimization {
|
||||
enable = true
|
||||
keepRules {
|
||||
files.add(File(projectDir, "common-proguard-rules.pro"))
|
||||
files.add(getDefaultProguardFile("proguard-android-optimize.txt"))
|
||||
|
||||
// Depending on whether the app flavor is enterprise or not we want to use different proguard rules.
|
||||
val flavorProguardFile = if (isEnterpriseBuild) {
|
||||
// Custom rules for enterprise builds
|
||||
File(projectDir, "enterprise-proguard-rules.pro")
|
||||
} else {
|
||||
// These default rules prevent the OSS app from being obfuscated
|
||||
File(projectDir, "default-proguard-rules.pro")
|
||||
}
|
||||
|
||||
if (flavorProguardFile.exists()) {
|
||||
files.add(flavorProguardFile)
|
||||
} else {
|
||||
logger.warn("Proguard file ${flavorProguardFile.absolutePath} does not exist")
|
||||
}
|
||||
// Equivalent of adding `getDefaultProguardFile("proguard-android-optimize.txt")` (this is the default value).
|
||||
includeDefault = true
|
||||
}
|
||||
// Our custom keep rules are registered as `keepRules` source folders in the `androidComponents` block below,
|
||||
// as the former `keepRules.files` DSL is deprecated since AGP 9.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,6 +216,30 @@ androidComponents {
|
||||
)
|
||||
|
||||
onVariants { variant ->
|
||||
// Register the R8 keep rules source folders for optimized build types (release, nightly).
|
||||
// Replaces the deprecated `optimization.keepRules.files` DSL (AGP 9+).
|
||||
if (variant.buildType != "debug") {
|
||||
variant.sources.keepRules?.let { keepRules ->
|
||||
// Common rules, always applied.
|
||||
keepRules.addStaticSourceDirectory("proguard/common")
|
||||
|
||||
// Depending on whether the app flavor is enterprise or not we want to use different proguard rules.
|
||||
val flavorProguardDir = if (isEnterpriseBuild) {
|
||||
// Custom rules for enterprise builds
|
||||
"../enterprise/proguard"
|
||||
} else {
|
||||
// Custom fules for FOSS builds
|
||||
"proguard/foss"
|
||||
}
|
||||
|
||||
if (File(projectDir, flavorProguardDir).exists()) {
|
||||
keepRules.addStaticSourceDirectory(flavorProguardDir)
|
||||
} else {
|
||||
logger.warn("Proguard folder ${File(projectDir, flavorProguardDir).absolutePath} does not exist")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assigns a different version code for each output APK
|
||||
// other than the universal APK.
|
||||
variant.outputs.forEach { output ->
|
||||
|
||||
Reference in New Issue
Block a user