Skip to content

Commit

Permalink
Added rules for required for engine and datacapture libraries. (#1916)
Browse files Browse the repository at this point in the history
* Added rules for required for engine and datacatpure

* Added consumerProguardFile for engine and catalog library

* Review comments: Removed unnecessary rules

* Review comments: Added comments

* Enabled minfying for catalog and demo release apps. Also removed unnecessary keep rule from catalog's rule file

* updated rules

* Added comments about new rules
  • Loading branch information
aditya-07 committed Jun 13, 2024
1 parent 8878362 commit 70fd2ae
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 22 deletions.
4 changes: 2 additions & 2 deletions catalog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"))
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
Expand Down
21 changes: 21 additions & 0 deletions catalog/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts
#
# For more details, see
# http:https://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

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

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
1 change: 1 addition & 0 deletions datacapture/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ android {
testInstrumentationRunner = Dependencies.androidJunitRunner
// Need to specify this to prevent junit runner from going deep into our dependencies
testInstrumentationRunnerArguments["package"] = "com.google.android.fhir.datacapture"
consumerProguardFile("proguard-rules.pro")
}

buildFeatures { viewBinding = true }
Expand Down
11 changes: 11 additions & 0 deletions datacapture/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## HAPI Strucutres need to be kept beause
# 1. Reflection is used in resource extraction as the FHIR Path expression is then translated to field names to locate data elements in FHIR resources.
# 2. In HAPI Strucures, ClassLoader is used to load classes from different packages that are hardcoded.
-keep class ca.uhn.fhir.** { *; }
-keep class org.hl7.fhir.** { *; }
# Used by hapi's XmlUtil which is internally used by hapi's FHIRPathEngine.
-keep class com.ctc.wstx.stax.** { *; }
# Used by HapiWorkerContext (fhirpath engine in QuestionnaireViewModel)
-keep class com.github.benmanes.caffeine.cache.** { *; }
## hapi libs ends
-ignorewarnings
2 changes: 1 addition & 1 deletion demo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
}
buildTypes {
release {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
Expand Down
1 change: 1 addition & 0 deletions engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ android {
testInstrumentationRunner = Dependencies.androidJunitRunner
// need to specify this to prevent junit runner from going deep into our dependencies
testInstrumentationRunnerArguments["package"] = "com.google.android.fhir"
consumerProguardFile("proguard-rules.pro")

javaCompileOptions {
annotationProcessorOptions {
Expand Down
39 changes: 20 additions & 19 deletions engine/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http:https://developer.android.com/guide/developing/tools/proguard.html
## HAPI Strucutres need to be kept beause
# 1. Reflection is used in resource extraction as the FHIR Path expression is then translated to field names to locate data elements in FHIR resources.
# 2. In HAPI Strucures, ClassLoader is used to load classes from different packages that are hardcoded.
-keep class ca.uhn.fhir.** { *; }
-keep class org.hl7.fhir.** { *; }
# Used by hapi's XmlUtil which is internally used by hapi's FHIRPathEngine.
-keep class com.ctc.wstx.stax.** { *; }
# Used by HapiWorkerContext (fhirpath engine in QuestionnaireViewModel)
-keep class com.github.benmanes.caffeine.cache.** { *; }
## hapi libs ends

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
## sqlcipher starts
# see (https://github.com/sqlcipher/android-database-sqlcipher/tree/master#proguard)
-keep,includedescriptorclasses class net.sqlcipher.** { *; }
-keep,includedescriptorclasses interface net.sqlcipher.** { *; }
## sqlcipher ends

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

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
## retrofit starts
# see (https://github.com/square/retrofit/issues/3539)
-keep class com.google.android.fhir.sync.remote.RetrofitHttpService { *; }
## retrofit ends
-ignorewarnings

0 comments on commit 70fd2ae

Please sign in to comment.