Proguard Top Level Obfuscation

Hopefully, I can find someone with some Proguard JAVA obfuscation experience.

Here's their website,

I have a java servlet application with a directory structure as follows:

I'm finding when I run proguard on this application using ant and specify the directory at this level, the obfuscated output jar file looks like this.

That is, the top level servlets don't get obfuscated. I've attached the proguard configuration file.
Does anyone know how to configure proguard to obfuscate the top level servlets?

x comes from the defaultpackage specification in the configuration file.

-injars '..\app.jar'
-outjars '..\o_app.jar'
-libraryjars '..\lib\rt_6_0.jar'
-libraryjars '..\lib\servlet-api.jar'
-defaultpackage x
# Keep - Servlets. Keep all extensions of javax.servlet.Servlet.
-keep public class * extends javax.servlet.Servlet
# Also keep - Enumerations. Keep a method that is required in enumeration
# classes.
-keepclassmembers class * extends java.lang.Enum {
    public **[] values();
# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembernames class * {
    native <methods>;
#Javascript classes
-keepnames class netscape.javascript.JSObject
-keepnames class netscape.javascript.JSException
# Remove debugging - Throwable_printStackTrace calls. Remove all invocations of
# Throwable.printStackTrace().
-assumenosideeffects public class java.lang.Throwable {
    public void printStackTrace();
# Remove debugging - All Log4j API calls. Remove all invocations of the
# Log4j API whose return values are not used.
-assumenosideeffects public class org.apache.log4j.** {

Open in new window

Who is Participating?
CEHJConnect With a Mentor Commented:
Those top level classes should be in a package anyway, so why not move them into one?
objectsConnect With a Mentor Commented:
> -keep public class * extends javax.servlet.Servlet

your telling it to keep servlets

which you'd want to do so your config does not break

lcorAuthor Commented:
I figured moving to a package was what I needed to do but was *hoping* otherwise.
we teach our students and web developers to always use packages. Avoids all the gotchas encountered when using the default package.
Good to hear you got it sorted :)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.