Developers, Developers, Developers! Maksim Sorokin IT Blog

12Oct/10Off

Using Newer Proguard in proguard-maven-plugin

proguard-maven-plugin currently is at version 2.0.4. And it is using net.sf.proguard:proguard dependency of version 4.3, which correspond to released version of ProGuard version 4.3.

As you may know, there are newer version available. So if you want to use newer version, simply add <proguardVersion>version</proguardVersion> and provide necessary plugin dependency as it is shown on Introduction page of proguard-maven-plugin

In my case I wasted a lot of hours trying to understand, why after obfuscation certain class was failed to initialize with Exception:

java.lang.NoClassDefFoundError: Could not initialize class

After a huge amount of try-outs and testing, I found out that it relates to ProGuard bug, which was fixed in version 4.4.
The thing is that I had some final static string, which contained , which had different representation in compiled classes starting from JDK6u11. However, ProGuard dealt with it some old way.

Tagged as: Comments Off
25Aug/10Off

Building Obfuscated Signed Java Web Start Applications with Maven

I have Java Web Start application with several libraries, some of which I want to obfuscate before the release. Unfortunately, I cannot use Webstart Maven Plugin since it works correctly only when all the dependencies, which will be assembled, are already present in the repository. In my case, I want to obfuscate libraries on-the-fly, sign them, put into zip file and deploy to my repository.

Instead, I attach the following chain of plugins to maven build lifecycle:

  1. Download keystore (refer to my older post
  2. Download all dependencies (except ones, which I will obfuscate) with Maven Dependency Plugin
  3. Run ProGuard on needed jars with Maven ProGuard Plugin
  4. Sign all the jars with Maven Jarsigner Plugin
  5. Filter JNLP file with Maven Resources Plugin
  6. Assemble application with Maven Assembly Plugin
23Aug/10Off

Obfuscating Several Jars in One Single Maven Build with ProGuard

ProGuard is nice and free tool for obfuscating your code. Actually, it can do a lot more: shrink, optimize and verify your application. But here we will stick solely on obfuscating several jars in one build with ProGuard and Maven.

There are some documentation on ProGuard Maven Plugin website, something on Stack Overflow and ofcourse in official documentation.

Say, you have a complex Java Web Start application consisting of several modules. And you want to obfuscate each module before release. Of course, you do not want to obfuscate for internal usage, but want to do it only before release. What you can do is to use