From b924b50d0093339a46c2729b7e57ce3a6c6909c2 Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Mon, 18 Sep 2023 11:30:58 +0200 Subject: [PATCH 1/3] feature: Disable Obfuscation Closes: #5 Signed-Off-By: Andre Weber --- kuksa-sdk/build.gradle.kts | 9 ------- kuksa-sdk/consumer-rules.pro | 6 ----- kuksa-sdk/proguard-rules.pro | 46 ------------------------------------ samples/build.gradle.kts | 9 ------- samples/proguard-rules.pro | 21 ---------------- 5 files changed, 91 deletions(-) delete mode 100644 kuksa-sdk/proguard-rules.pro delete mode 100644 samples/proguard-rules.pro diff --git a/kuksa-sdk/build.gradle.kts b/kuksa-sdk/build.gradle.kts index d838e3d8..2b5d0b87 100644 --- a/kuksa-sdk/build.gradle.kts +++ b/kuksa-sdk/build.gradle.kts @@ -19,15 +19,6 @@ android { consumerProguardFiles("consumer-rules.pro") } - buildTypes { - release { - isMinifyEnabled = true - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro", - ) - } - } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 diff --git a/kuksa-sdk/consumer-rules.pro b/kuksa-sdk/consumer-rules.pro index 4a2ef0d2..e69de29b 100644 --- a/kuksa-sdk/consumer-rules.pro +++ b/kuksa-sdk/consumer-rules.pro @@ -1,6 +0,0 @@ --keep,allowobfuscation,allowoptimization,allowshrinking class org.eclipse.kuksa.DataBrokerConnection { *; } --keep,allowobfuscation,allowoptimization,allowshrinking class org.eclipse.kuksa.DataBrokerConnector { *; } --keep,allowobfuscation,allowoptimization,allowshrinking class org.eclipse.kuksa.model.Property { *; } --keep,allowobfuscation,allowoptimization,allowshrinking interface org.eclipse.kuksa.PropertyObserver { *; } --keep,allowobfuscation,allowoptimization,allowshrinking class org.eclipse.kuksa.CoroutineCallback { *; } --keep,allowobfuscation,allowoptimization,allowshrinking class org.eclipse.kuksa.TimeoutConfig { *; } diff --git a/kuksa-sdk/proguard-rules.pro b/kuksa-sdk/proguard-rules.pro deleted file mode 100644 index 6dfa2cd0..00000000 --- a/kuksa-sdk/proguard-rules.pro +++ /dev/null @@ -1,46 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://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 - --dontwarn java.lang.invoke.StringConcatFactory - -# don't shrink/remove classes; even if unused -# don't shrink/remove public methods and fields; even if unused -# don't rename class and public/protected methods / field names -# but rename private methods and fields --keep class org.eclipse.kuksa.DataBrokerConnection { - public protected *; -} - --keep class org.eclipse.kuksa.DataBrokerConnector { - public protected *; -} - --keep class com.etas.kuksa.sdk.model.** { - public protected *; -} - --keep class org.eclipse.kuksa.TimeoutConfig { *; } --keep interface org.eclipse.kuksa.DataBrokerException { *; } --keep interface org.eclipse.kuksa.PropertyObserver { *; } - -# used for java compatibility --keep class org.eclipse.kuksa.CoroutineCallback { *; } diff --git a/samples/build.gradle.kts b/samples/build.gradle.kts index 5c6767f3..fbd3a382 100644 --- a/samples/build.gradle.kts +++ b/samples/build.gradle.kts @@ -15,15 +15,6 @@ android { } } - buildTypes { - release { - isMinifyEnabled = false - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro", - ) - } - } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/samples/proguard-rules.pro b/samples/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/samples/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://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 \ No newline at end of file From 3d82ab3f9efa62ae3518397e5ffaa93588017c61 Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Mon, 18 Sep 2023 11:31:34 +0200 Subject: [PATCH 2/3] chore: Enable Shrinking for TestApp when Build with "minify" Property To easily locate shrinking issues (e.g. missing Proguard Consumer rules) I enabled shrinking for the TestApp when it is build with the optional parameter "minify". --- app/build.gradle.kts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1f327942..cc84115b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -33,10 +33,17 @@ android { } } buildTypes { - debug { isMinifyEnabled = false } - release { - isMinifyEnabled = true - proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + // for local builds, used to find shrinking issues + val isMinify = project.hasProperty("minify") + if (isMinify) { + debug { + // while isDebuggable is set to true no obfuscation takes place, + // the shrinking phase will still remove unused classes + isDebuggable = true + + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } } } namespace = "org.eclipse.kuksa.testapp" @@ -96,3 +103,10 @@ dependencies { implementation(libs.androidx.activity.compose) } + +tasks.register("testTask") { + val hasProperty = project.hasProperty("minify") + doLast { + println("minify: $hasProperty") + } +} From dc2d9e2014f8f394a67644985320b219a0d17b5a Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Mon, 18 Sep 2023 11:43:46 +0200 Subject: [PATCH 3/3] chore: Remove Gradle Testing Task --- app/build.gradle.kts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cc84115b..e92268c9 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -103,10 +103,3 @@ dependencies { implementation(libs.androidx.activity.compose) } - -tasks.register("testTask") { - val hasProperty = project.hasProperty("minify") - doLast { - println("minify: $hasProperty") - } -}