Solving problems

If the obfuscate4e plugin does not work as expected, then you have some possibilities at hand.

  • If the obfuscation works manually at first run, but not at subsequent runs: Refresh the Eclipse workspace and check if there is a folder @dot or temp.folder in the plugin project. If they are, then remove it. Eclipse PDE build doesn’t run the customBuildCallbacks if they exist.
  • Check the obfuscation setting in the proguard.cfg file in your plugin project. The syntax of this file is explained at the Proguard website (look at the Usage section).
  • Run the obfuscation in verbose mode. Ant produces some output which might show the problem.
  • Go to the bug tracker, there might be solutions matching your problem.
  • If you encountered a bug, then you might submit a bug report.

Please submit the following information:

  • The version of your Java and Eclipse installations,
  • The contents of proguard.cfg and temp.folder/proguard.map, if available,
  • The output of the verbose mode Ant run (see next section for details),
  • optionally the MANIFEST.MF of the plugin (to ease the check of the proguard configuration).

Inspect the obfuscated product

It is quite easy to look how obfuscate4e processed your product. You need a de-compiler and an exported Eclipse RCP product. I’ll describe the procedure on a linux box.

I use Jode. This Project seems “dead”, at least there were no new releases since 2004. But it works well for this job.

Download the latest jode distribution and extract the file jode*.jar. Then open a shell an go to the folder where you exported the product to. Now execute the command shown below:

java -jar ~/Apps/jode-1.1.2-pre1.jar $(echo plugins/*  | tr " " ",")

The $(echo plugins/* | tr " " ",") selects all jars and folders inside the plugins/ directory and compiles tthem into a comma separated list. That’s how jode expects the resources to be inspected.

A window pops up and you can traverse the class structure and look at the obfuscated build.

screenshot-jode.png

Run the obfuscator in verbose mode

It might happen that the obfuscation does not work as expected. In this case there may be some "strange" folders in your project and the generated plugin jar contains non-obfuscated classes.

But the build process runs in headless mode and no errors or warnings are printed out in the console view.

The easiest way to debug the obfuscation process is to create and execute a build.xml file for the plugin.

At first generate a build.xml file by clicking on PDE Tools > Create Ant Build File in the context menu of the project or the META-INF/MANIFEST.MF file.
Then run the build.xml file by clicking the Run As > Ant Build entry of the context menu of the build.xml file.
The output of the plugin build is shown in the console view. Warnings and error messages are highlighted.

Run the build script

The target post.@dot contains the messages relevant to the obfuscation. In the above screenshot there is a error message:

[subant] Failure for target 'post.@dot' of:
          /prj/de.partmaster.mytest/customBuildCallbacks.xml
[subant] The following error occurred while executing this line:
[subant] /prj/de.partmaster.mytest/customBuildCallbacks.xml:119:
          Problem: failed to create task or type proguard
[subant] Cause: The name is undefined.
[subant] Action: Check the spelling.
[subant] Action: Check that any custom tasks/types have been declared.
[subant] Action: Check that any <presetdef>/<macrodef> 
            declarations have taken place.

In this case Ant could not find the declaration of the proguard task. This should not happen in practice – otherwise check your Eclipse installation in Help > Software Updates > Manage configuration for broken plugin dependencies.
As a rule of thumb you should follow make sure that you

  1. rebuild the customBuildCallbacks.xml file if you change the package structure of the plugin,
  2. rebuild the build.xml file if you change anything in customBuildCallbacks.xml.
  3. run the build.xml script in verbose mode if you cant find the error.
  4. Attach the verbose console output together with the file proguard.properties to any bug report and name the version of Java and Eclipse you are using.