# Avoid shrinking and optimization to ensure the app works as expected -dontshrink -dontoptimize # Enable unique class member names and adapt class strings -useuniqueclassmembernames -adaptclassstrings # Suppress warnings (for reduced clutter) -dontnote -ignorewarnings -dontwarn # Enable control flow obfuscation to scramble the logic and confuse decompilers -optimizations !code/simplification/arithmetic,!method/inline,!class/merging # Add dead code to confuse decompilers and make reverse engineering harder -assumenosideeffects class ** { public void set*(***); } # Repackage obfuscated classes into a specific package -repackageclasses org.test.guarded # Move obfuscated classes to this package # Use a dictionary for class, method, and field renaming to randomize names -classobfuscationdictionary class-names.txt # Class names using proguard.txt dictionary -obfuscationdictionary obf-names.txt # Method/field names using proguard.txt dictionary # Keep necessary Spring classes for reflection and DI to avoid breaking functionality -keep class * extends org.springframework.boot.web.support.SpringBootServletInitializer { *; } -keep class * extends org.springframework.boot.loader.** { *; } # Keep main method for the application entry point -keepclasseswithmembers public class * { public static void main(java.lang.String[]); } # Keep only the necessary Spring annotations for DI and related functionality -keepclassmembers class * { @org.springframework.beans.factory.annotation.Autowired *; @org.springframework.beans.factory.annotation.Qualifier *; @org.springframework.beans.factory.annotation.Value *; @org.springframework.beans.factory.annotation.Required *; @org.springframework.context.annotation.Bean *; @org.springframework.context.annotation.Primary *; @org.springframework.boot.context.properties.ConfigurationProperties *; @org.springframework.boot.context.properties.EnableConfigurationProperties *; } # Spring-specific classes for caching and configuration -keep @org.springframework.cache.annotation.EnableCaching class * -keep @org.springframework.context.annotation.Configuration class * -keep @org.springframework.boot.context.properties.ConfigurationProperties class * -keep @org.springframework.boot.autoconfigure.SpringBootApplication class * -keep @org.springframework.stereotype.Repository class * # Allow method and field name obfuscation -allowaccessmodification # Keep specific attributes for debugging (e.g., Exceptions, Signature, etc.) -keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod,RuntimeVisibleAnnotations # Keep specific directories used by Spring Boot (e.g., auto-configuration) -keepdirectories org.springframework.boot.autoconfigure # Keep specific methods for class loading (used by Spring) -keepclassmembernames class * { java.lang.Class class$(java.lang.String); java.lang.Class class$(java.lang.String, boolean); } # Keep Serializable classes from obfuscation -keep class * implements java.io.Serializable # Keep enum members -keepclassmembers enum * { *; } # Keep critical response classes and DTOs -keep class org.test.api.response.CustomResponse { *; } -keep class org.test.model.** { *; } #DTO -keep class org.test.repository.** { *; } #Spring Data -keep class org.test.entity.** { *; } #Database entities # Keep specific classes and members for your app based on reflection and DI needs -keeppackagenames org.test.api.controllers -keepnames class org.test.api.controllers # Keep specific classes and members for security configurations -keepclassmembernames class org.test.api.auth.** { *; } # Spring Security -keepclassmembernames class org.test.api.configs.WebFluxSecurityConfig { *; } # Spring Security -keepclassmembernames @interface * { *; } -keepclassmembernames class org.test.api.repository.** { *; } -keepclassmembernames class org.test.api.entity.** { *; } -keepclassmembernames class org.test.api.model.** { *; } # Enable more aggressive optimizations where applicable -optimizations !method/inlining # Keep all fields in org.test.guarded if they're serialized (for persistence) -keepclassmembers class org.test.guarded.** { *; } # Minimize side effects and avoid unnecessary warnings -dontskipnonpubliclibraryclasses -dontusemixedcaseclassnames # Additional configurations to make code harder to understand after obfuscation -dontwarn com.example.app.** -optimizationpasses 5 -optimizations !code/simplification/arithmetic,!method/inlining,!class/merging -overloadaggressively -flattenpackagehierarchy -keepattributes !SourceFile,!LineNumberTable