Richard Fung
Richard Fung

Reputation: 1020

proguard removing things I specified with keep

I'm trying to configure proguard to only shrink my jar and also to only remove fields in the packages com.faster.xml**, com.amazonaws.javax., com.amazonaws.org.apache., org.apache.commons., and org.joda.. To do this, I've used the following in my proguard config:

-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers

-dontobfuscate
-dontoptimize
-dontpreverify
-keepattributes

-keep enum ** { *; }
-keep class !com.fasterxml.**, !com.amazonaws.javax.**,
        !com.amazonaws.org.apache.**, !org.apache.commons.**, !org.joda.**,
        ** { *; }

However, I've noticed that things which are not in the namespaces specified are still getting removed. The jar still appears to be working, but I just wanted to understand what it's doing exactly.

Upvotes: 1

Views: 102

Answers (1)

Eric Lafortune
Eric Lafortune

Reputation: 45686

Your configuration explicitly preserves all classes, fields, and methods, except the ones in the specified packages. That should be what you want. You can check the effect of your configuration with

-printseeds seeds.txt

The generated file contains a list of the explicitly preserved classes, fields, and methods.

If some classes seem to disappear, you should double-check the input directories or input jars. You can also check if the -injars or -outjars options in your configuration have filters.

Upvotes: 1

Related Questions