Let’s define an object
package aaa
trait Keep
trait Toto extends Keep { def a: Int }
object Toto extends Keep {
def apply(i: Int): Int = new Toto { val a: Int = i }
}
Exclude it from obfuscating class
-keep class * extends aaa.Keep
-keep class * implements aaa.Keep
-keep class * extends aaa.Keep {*;}
-keep class * implements aaa.Keep {*;}
After obfuscation when exploring the jar i can see class Toto and Toto$ with theirs methods as on non obfuscated jar.
Now on another project depending of the obfuscated jar.
import aaa.Toto
val zero = Toto(0)
My IDEA ide reconize the Toto class and apply method but when i compile i fall on
error: class aaa.Toto is not a value.
Here are my other options
"-dontnote",
"-dontwarn",
"-ignorewarnings",
"-dontskipnonpubliclibraryclassmembers",
"-dontoptimize",
"-keepparameternames",
"-keeppackagenames aaa.*",
"-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod,MethodParameters,ConstantValue,Module,ModulePackages,LocalVariableTable,LocalVariableTypeTable",
"-keep interface org.** { *; }",
"-keep class org.** { *; }",
"-keep enum org.** { *; }",
"-keep class * implements org.xml.sax.EntityResolver",
"-keepclassmembers class * {** MODULE$;}",
"-keep class * implements jline.Completor",
"-keep class * implements jline.Terminal",
"-keepclasseswithmembernames class * {native <methods>;}",
"-keepclasseswithmembers class * {<init>(scala.tools.nsc.Global);}",
"-keep class scala.tools.nsc.Global",
"-keepclassmembers,allowoptimization enum * {public static **[] values();public static ** valueOf(java.lang.String);}",
"-keepclassmembernames class * {java.lang.Class class$(java.lang.String);java.lang.Class class$(java.lang.String, boolean);}",
I probably forget an exclusion rule for a specific aspect but i cannot figure out which one.
How is it possible to call scala object methods on the obfuscated jar knowing the object is -keep ?
Kind Regards
Gaël