2

I'm using the com.github.wvengen:proguard-maven-plugin:2.3.1 maven plugin to obfuscate my jars when building my project. Besides obfuscating, I'm also trying to repackage all classes to the root package. All worked fine and all the classes were moved to the root package until I had to configure the prevention of a class' obfuscation. The classes from the same package as the class I'm trying to prevent from obfuscation do not get moved to the root package. The config I'm using:

<configuration>
  <proguardVersion>7.0.0</proguardVersion>
  <injar>${project.build.finalName}.jar</injar>
  <outjar>${project.build.finalName}-obf.jar</outjar>
  <obfuscate>true</obfuscate>
  <mappingFileName>mapping.txt</mappingFileName>
  <seedFileName>seeds.txt</seedFileName>
  <options>
    <option>-dontoptimize</option>
    <option>-dontshrink</option>
    <option>-dontnote **</option>
    <option>-dontwarn **</option>
    <option>-repackageclasses</option>
    <option>-keep class me.myname.mypkg.Main</option>
  </options>
  <libs>
    <lib>${java.home}/lib/rt.jar</lib>
  </libs>
</configuration>

Let's say I have the following unobfuscated jar:

├─com
│ └─somename
│   └─somepkg
│     ├─otherpkg
│     │ └─OtherClass.class
│     └─SomeClass.class
└─me
  └─myname
    └─mypkg
      ├─util
      │ └─Util.class
      ├─Main.class
      ├─Manager.class
      └─MyApp.class

When passed through ProGuard (7.0.0) using the configuration above I get the following out jar:

├─me
│ └─myname
│   └─mypkg
│     ├─a.class     # - MyApp.class
│     ├─A.class     # - Manager.class
│     └─Main.class
├─a.class           # - OtherClass.class
├─A.class           # - SomeClass.class
└─b.class           # - Util.class

See how Main.class package's classes don't get moved to the root package? This behaviour occurs on both official proguard and the maven plugin. Is this intended? If so, how can I still move ALL classes to the root package even if I keep a class unobfuscated?

alextusinean
  • 21
  • 1
  • 2

0 Answers0