Skip to content

Commit 2f935e2

Browse files
committed
build: Add proguard to library modules
Signed-off-by: andresmr <[email protected]>
1 parent ef58ca1 commit 2f935e2

File tree

21 files changed

+154
-33
lines changed

21 files changed

+154
-33
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import com.android.build.api.variant.impl.VariantOutputImpl
2-
import com.android.build.gradle.internal.scope.ProjectInfo.Companion.getBaseName
32
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
43
import java.io.ByteArrayOutputStream
54
import java.text.SimpleDateFormat
@@ -146,7 +145,7 @@ android {
146145
isShrinkResources = true
147146
isMinifyEnabled = true
148147
proguardFiles(
149-
getDefaultProguardFile("proguard-android.txt"),
148+
getDefaultProguardFile("proguard-android-optimize.txt"),
150149
"proguard-rules.pro"
151150
)
152151
signingConfig = signingConfigs.getByName("release")

app/proguard-rules.pro

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,26 @@
2424
# hide the original source file name.
2525
-renamesourcefileattribute SourceFile
2626

27+
# Keep Hilt-generated components and entry points
28+
-keep class dagger.** { *; }
29+
-keep class hilt.** { *; }
30+
-keep class dagger.hilt.** { *; }
31+
-keep class androidx.hilt.** { *; }
32+
-keep class javax.inject.** { *; }
33+
-keep class dagger.internal.** { *; }
34+
-keep class dagger.multibindings.** { *; }
35+
-keep interface dagger.hilt.EntryPoint
36+
-keep interface dagger.hilt.InstallIn
37+
-keep @dagger.hilt.components.SingletonComponent class *
38+
# Keep DataBinding classes
39+
-keep class androidx.databinding.** { *; }
40+
-keep class **.databinding.** { *; }
41+
42+
# Keep @Provides, @Binds, and other annotations
43+
-keepattributes *Annotation*
44+
-keepattributes InnerClasses
45+
-keepattributes EnclosingMethod
46+
2747
-dontwarn autovalue.shaded.com.google$.errorprone.annotations.$CanIgnoreReturnValue
2848
-dontwarn autovalue.shaded.com.google$.errorprone.annotations.concurrent.$LazyInit
2949
-dontwarn com.android.org.conscrypt.SSLParametersImpl

commons/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ android {
3131
getByName("debug") {
3232
}
3333
getByName("release") {
34-
isMinifyEnabled = false
34+
isMinifyEnabled = true
3535
proguardFiles(
3636
getDefaultProguardFile("proguard-android-optimize.txt"),
3737
"proguard-rules.pro"

commons/proguard-rules.pro

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@
1414

1515
# Uncomment this to preserve the line number information for
1616
# debugging stack traces.
17-
#-keepattributes SourceFile,LineNumberTable
17+
-keepattributes SourceFile,LineNumberTable
1818

1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
21-
#-renamesourcefileattribute SourceFile
21+
-renamesourcefileattribute SourceFile
22+
23+
# Keep ResourceManager
24+
-keep class org.dhis2.commons.resources.ResourceManager { *; }
25+
26+
# Keep DispatcherProvider
27+
-keep class org.dhis2.commons.viewmodel.DispatcherProvider { *; }
28+
29+
-dontwarn java.lang.invoke.StringConcatFactory

compose-table/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ android {
2424
getByName("debug") {
2525
}
2626
getByName("release") {
27-
isMinifyEnabled = false
27+
isMinifyEnabled = true
2828
proguardFiles(
2929
getDefaultProguardFile("proguard-android-optimize.txt"),
3030
"proguard-rules.pro"

compose-table/proguard-rules.pro

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,19 @@
1414

1515
# Uncomment this to preserve the line number information for
1616
# debugging stack traces.
17-
#-keepattributes SourceFile,LineNumberTable
17+
-keepattributes SourceFile,LineNumberTable
1818

1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
21-
#-renamesourcefileattribute SourceFile
21+
-renamesourcefileattribute SourceFile
22+
23+
24+
# Keep KeyboardInputType and its nested classes
25+
-keep class org.dhis2.composetable.model.KeyboardInputType { *; }
26+
-keep class org.dhis2.composetable.model.KeyboardInputType$* { *; }
27+
28+
# Keep ValidationResult and its nested classes
29+
-keep class org.dhis2.composetable.model.ValidationResult { *; }
30+
-keep class org.dhis2.composetable.model.ValidationResult$* { *; }
31+
32+
-dontwarn java.lang.invoke.StringConcatFactory

dhis2-mobile-program-rules/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ android {
2020

2121
buildTypes {
2222
release {
23-
isMinifyEnabled = false
23+
isMinifyEnabled = true
2424
proguardFiles(
2525
getDefaultProguardFile("proguard-android-optimize.txt"),
2626
"proguard-rules.pro"

dhis2-mobile-program-rules/proguard-rules.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
# Uncomment this to preserve the line number information for
1616
# debugging stack traces.
17-
#-keepattributes SourceFile,LineNumberTable
17+
-keepattributes SourceFile,LineNumberTable
1818

1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
21-
#-renamesourcefileattribute SourceFile
21+
-renamesourcefileattribute SourceFile

dhis2_android_maps/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ android {
2525
getByName("debug") {
2626
}
2727
getByName("release") {
28-
isMinifyEnabled = false
28+
isMinifyEnabled = true
2929
proguardFiles(
3030
getDefaultProguardFile("proguard-android-optimize.txt"),
3131
"proguard-rules.pro"

dhis2_android_maps/proguard-rules.pro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414

1515
# Uncomment this to preserve the line number information for
1616
# debugging stack traces.
17-
#-keepattributes SourceFile,LineNumberTable
17+
-keepattributes SourceFile,LineNumberTable
1818

1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
21-
#-renamesourcefileattribute SourceFile
21+
-renamesourcefileattribute SourceFile
22+
23+
-dontwarn org.dhis2.commons.bindings.BindingsKt
24+
-dontwarn org.dhis2.commons.data.ProgramEventViewModel

0 commit comments

Comments
 (0)