Skip to content

Commit

Permalink
build: Add proguard to library modules
Browse files Browse the repository at this point in the history
Signed-off-by: andresmr <[email protected]>
  • Loading branch information
andresmr committed Nov 28, 2024
1 parent ef58ca1 commit 2f935e2
Show file tree
Hide file tree
Showing 21 changed files with 154 additions and 33 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import com.android.build.api.variant.impl.VariantOutputImpl
import com.android.build.gradle.internal.scope.ProjectInfo.Companion.getBaseName
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.io.ByteArrayOutputStream
import java.text.SimpleDateFormat
Expand Down Expand Up @@ -146,7 +145,7 @@ android {
isShrinkResources = true
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android.txt"),
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
Expand Down
20 changes: 20 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@
# hide the original source file name.
-renamesourcefileattribute SourceFile

# Keep Hilt-generated components and entry points
-keep class dagger.** { *; }
-keep class hilt.** { *; }
-keep class dagger.hilt.** { *; }
-keep class androidx.hilt.** { *; }
-keep class javax.inject.** { *; }
-keep class dagger.internal.** { *; }
-keep class dagger.multibindings.** { *; }
-keep interface dagger.hilt.EntryPoint
-keep interface dagger.hilt.InstallIn
-keep @dagger.hilt.components.SingletonComponent class *
# Keep DataBinding classes
-keep class androidx.databinding.** { *; }
-keep class **.databinding.** { *; }

# Keep @Provides, @Binds, and other annotations
-keepattributes *Annotation*
-keepattributes InnerClasses
-keepattributes EnclosingMethod

-dontwarn autovalue.shaded.com.google$.errorprone.annotations.$CanIgnoreReturnValue
-dontwarn autovalue.shaded.com.google$.errorprone.annotations.concurrent.$LazyInit
-dontwarn com.android.org.conscrypt.SSLParametersImpl
Expand Down
2 changes: 1 addition & 1 deletion commons/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
getByName("debug") {
}
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
12 changes: 10 additions & 2 deletions commons/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

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

# Keep ResourceManager
-keep class org.dhis2.commons.resources.ResourceManager { *; }

# Keep DispatcherProvider
-keep class org.dhis2.commons.viewmodel.DispatcherProvider { *; }

-dontwarn java.lang.invoke.StringConcatFactory
2 changes: 1 addition & 1 deletion compose-table/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
getByName("debug") {
}
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
15 changes: 13 additions & 2 deletions compose-table/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

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


# Keep KeyboardInputType and its nested classes
-keep class org.dhis2.composetable.model.KeyboardInputType { *; }
-keep class org.dhis2.composetable.model.KeyboardInputType$* { *; }

# Keep ValidationResult and its nested classes
-keep class org.dhis2.composetable.model.ValidationResult { *; }
-keep class org.dhis2.composetable.model.ValidationResult$* { *; }

-dontwarn java.lang.invoke.StringConcatFactory
2 changes: 1 addition & 1 deletion dhis2-mobile-program-rules/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {

buildTypes {
release {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
4 changes: 2 additions & 2 deletions dhis2-mobile-program-rules/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-renamesourcefileattribute SourceFile
2 changes: 1 addition & 1 deletion dhis2_android_maps/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android {
getByName("debug") {
}
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
7 changes: 5 additions & 2 deletions dhis2_android_maps/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

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

-dontwarn org.dhis2.commons.bindings.BindingsKt
-dontwarn org.dhis2.commons.data.ProgramEventViewModel
2 changes: 1 addition & 1 deletion dhis_android_analytics/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
getByName("debug") {
}
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
15 changes: 13 additions & 2 deletions dhis_android_analytics/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

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

# Keep dhis2.org.analytics.charts.Charts
-keep class dhis2.org.analytics.charts.Charts { *; }

# Preserve attributes related to DataBinding
-keepattributes *Annotation*

-dontwarn org.dhis2.commons.bindings.CommonExtensionsKt
-dontwarn org.dhis2.commons.filters.data.FilterBindingsKt
-dontwarn org.dhis2.commons.resources.ColorType
-dontwarn org.dhis2.commons.resources.ColorUtils
2 changes: 1 addition & 1 deletion form/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {
getByName("debug") {
}
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
6 changes: 4 additions & 2 deletions form/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

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

-dontwarn java.lang.invoke.StringConcatFactory
2 changes: 1 addition & 1 deletion stock-usecase/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ android {

buildTypes {
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
71 changes: 69 additions & 2 deletions stock-usecase/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,75 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

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

# Keep Hilt-generated components and entry points
-keep class dagger.** { *; }
-keep class hilt.** { *; }
-keep class dagger.hilt.** { *; }
-keep class androidx.hilt.** { *; }
-keep class javax.inject.** { *; }
-keep class dagger.internal.** { *; }
-keep class dagger.multibindings.** { *; }
-keep interface dagger.hilt.EntryPoint
-keep interface dagger.hilt.InstallIn
-keep @dagger.hilt.components.SingletonComponent class *

# Keep runtime annotations for Hilt and Dagger
-keepattributes *Annotation*

# Keep ViewModels to ensure Hilt can reference them
-keep class org.dhis2.android.rtsm.ui.managestock.ManageStockViewModel { *; }
-keep class org.dhis2.android.rtsm.ui.home.HomeViewModel { *; }
-keep class org.dhis2.android.rtsm.ui.base.BaseViewModel { *; }
-keep class org.dhis2.android.rtsm.services.SpeechRecognitionManager { *; }
-keep class org.dhis2.android.rtsm.services.rules.RuleValidationHelper { *; }
-keep class org.dhis2.android.rtsm.services.StockManager { *; }
-keep class org.dhis2.android.rtsm.services.MetadataManager { *; }
-keep class org.dhis2.android.rtsm.services.scheduler.BaseSchedulerProvider { *; }
-keep class org.dhis2.android.rtsm.services.StockTableDimensionStore { *; }
-keep class org.dhis2.android.rtsm.ui.managestock.TableModelMapper { *; }

-dontwarn dhis2.org.analytics.charts.ui.GroupAnalyticsFragment$Companion
-dontwarn dhis2.org.analytics.charts.ui.GroupAnalyticsFragment
-dontwarn java.lang.invoke.StringConcatFactory
-dontwarn org.dhis2.commons.filters.FilterManager
-dontwarn org.dhis2.commons.orgunitselector.OUTreeFragment$Builder
-dontwarn org.dhis2.commons.orgunitselector.OUTreeFragment
-dontwarn org.dhis2.commons.orgunitselector.OrgUnitSelectorScope$ProgramCaptureScope
-dontwarn org.dhis2.commons.orgunitselector.OrgUnitSelectorScope
-dontwarn org.dhis2.commons.sync.OnDismissListener
-dontwarn org.dhis2.commons.sync.OnNoConnectionListener
-dontwarn org.dhis2.commons.sync.OnSyncNavigationListener
-dontwarn org.dhis2.commons.sync.SyncContext$TrackerProgram
-dontwarn org.dhis2.commons.sync.SyncContext
-dontwarn org.dhis2.commons.sync.SyncDialog
-dontwarn org.dhis2.composetable.TableConfigurationState
-dontwarn org.dhis2.composetable.TableScreenState
-dontwarn org.dhis2.composetable.TableState
-dontwarn org.dhis2.composetable.actions.TableResizeActions
-dontwarn org.dhis2.composetable.actions.Validator
-dontwarn org.dhis2.composetable.model.TableCell
-dontwarn org.dhis2.composetable.model.TextInputModel
-dontwarn org.dhis2.composetable.ui.DataSetTableScreenKt
-dontwarn org.dhis2.composetable.ui.TableColors
-dontwarn org.dhis2.composetable.ui.TableConfiguration
-dontwarn org.dhis2.composetable.ui.TableDimensions
-dontwarn org.dhis2.composetable.ui.TableThemeKt
-dontwarn org.dhis2.composetable.ui.semantics.TableSemanticsKt
-dontwarn org.dhis2.ui.buttons.FAButtonKt
-dontwarn org.dhis2.ui.dialogs.bottomsheet.BottomSheetDialog
-dontwarn org.dhis2.ui.dialogs.bottomsheet.BottomSheetDialogUiModel
-dontwarn org.dhis2.ui.dialogs.bottomsheet.DialogButtonStyle$DiscardButton
-dontwarn org.dhis2.ui.dialogs.bottomsheet.DialogButtonStyle$MainButton
-dontwarn org.dhis2.ui.dialogs.bottomsheet.DialogButtonStyle
-dontwarn org.dhis2.composetable.model.RowHeader
-dontwarn org.dhis2.composetable.model.TableHeader
-dontwarn org.dhis2.composetable.model.TableHeaderCell
-dontwarn org.dhis2.composetable.model.TableHeaderRow
-dontwarn org.dhis2.composetable.model.TableModel
-dontwarn org.dhis2.composetable.model.TableRowModel
2 changes: 1 addition & 1 deletion tracker/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {

buildTypes {
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
4 changes: 2 additions & 2 deletions tracker/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-renamesourcefileattribute SourceFile
6 changes: 2 additions & 4 deletions ui-components/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ android {
getByName("debug") {
}
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile(
"proguard-android-optimize.txt"
),
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
Expand Down
4 changes: 2 additions & 2 deletions ui-components/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-renamesourcefileattribute SourceFile
4 changes: 3 additions & 1 deletion viewpagerdotsindicator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ android {
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
testOptions.targetSdk = libs.versions.sdk.get().toInt()

consumerProguardFiles("consumer-rules.pro")
}
namespace = "com.tbuonomo.viewpagerdotsindicator"
buildTypes {
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down

0 comments on commit 2f935e2

Please sign in to comment.