|
GettingStarted
Configure the obfuscationNow it's time to configure how obfuscate4e and its embedded obfuscator should work. We use the ProGuard obfuscator in this sectin. The configuration of other obfuscators will differ. Execute the action Create Proguard obfuscation configuration from the context menu of the plugin MANIFEST.MF.
In the project folder appear two new files: customBuildCallbacks.xml and proguard.cfg. These files are managed inside your project (and also version controlled).
ProGuard allows to highly customize the obfuscation process. You can add cunfiguration statements to the proguard.cfg file. See http://proguard.sourceforge.net/manual/usage.html for valid configuration parameters. Excluding classes or packages from obfuscationObfuscate4e detects exported packages and and writes the corresponding obfuscation exclusion statements automatically into the file proguard.cfg at your plugin's root directory. Starting from version 0.7 of obfuscate4e all classes references from plugin extensions (in plugin.xml) are automatically inserted into the obfuscator exclusion list. Thus the obfuscate4e configuration should be updated whenever a new extension is added to the plugin. Of course you can add custom exclusion statements by hand. For instance If a class gets instantiated via reflection or is referenced by name in any other way, it has to be excluded. Exclude all classes in a packageBy default obfuscate4e adds all exported packages of a plugin to the exclusion list. There are to options if you want to add other packages to the exclution list:<!--break-->
-keep class de.example.plugin.* {
public protected *;
}Remark: If you modified the proguard.cfg file manually, then these changes will be lost when re-generating the configuration! Exclude a single classYou might want to exclude a certain file from obfuscation. This might be the case if the class is used in an extension of your plugin.<!--break--> To exclude a class from obfuscation you have to add a statement like -keep class de.example.plugin.actions.MySpecialAction {
public protected *;
}to the proguard.cfg file. All other classes in the package de.example.plugin.actions are completely obfuscated. Remark: If you modified the proguard.cfg file manually, then these changes will be lost when re-generating the configuration! Exclude all classes of a certain kindTo exclude all classes that implement a certain interface or extend a certain class (e.g. all views, actions, perspectives, wizards, ...) in a generic way you need to exclude the appropriate interfaces or super classes: -keep class * extends org.eclipse.ui.part.ViewPart {
public *;
}
-keep class * implements org.eclipse.jface.action.IAction {
public *;
}
-keep class * implements org.eclipse.ui.IPerspectiveFactory {
public *;
}
-keep class * implements org.eclipse.equinox.app.IApplication {
public *;
}
-keep class * implements org.eclipse.jface.wizard.IWizard {
public *;
}To exclude all access methods (getters and setters) there is another generic way: -keep class * implements org.example.AnyInterface {
void set*(***);
void set*(int, ***);
boolean is*();
boolean is*(int);
*** get*();
*** get*(int);
}Remark: If you modified the proguard.cfg file manually, then these changes will be lost when re-generating the configuration! Obfuscate your codeIt's time to use your obfuscator. As it is embedded into the built process Eclipse runs the obfuscator when exporting a plugin, a project or a complete product. Export a plugin with File > Export ...
The plugin will be obfuscated and exported. If you run the obfuscation in "verbose" mode, then you can see ant processing the plugin and check the applied names mapping in the file proguard.map. This file is located in the folder temp.folder/ of the plugin. This file shows a list of processed files as well as the names of class, fields and methods after obfuscation.
|