<ANTENNA/>

Antenna

An Ant-to-End Solution For Wireless Java

Version 1.2.1

(c) 2002-2010


Erik Wetterberg
Sourceforge project


News | Overview | Download | Setup | JAD | Build | Package | MakePRC | RAPC
Run | Preverify | Obfuscate | SmartLink | Preprocess | Deploy | Sign | History |

Using an obfuscator

To allow obfuscation, either RetroGuard or ProGuard is required. Simply put one (or both) of the following files into the WTK's "bin" directory or make sure you have at least one of them in your CLASSPATH:

retroguard.jar
proguard.jar
		
Alternatively, you can also set the following properties to the home directories of existing installations of the obfuscators (where home means the root directory of the software, which is, for ProGuard, one level higher than the lib directory where the JAR file is located):
<property name="wtk.retroguard.home" value="your path goes here"/>
<property name="wtk.proguard.home" value="your path goes here"/>
		

If both obfuscators are available, ProGuard is preferred because it usually provides better results.

Note that if using RetroGuard and setting a BOOTCLASSPATH through the wtk.midpapi property, it might also become necessary to set the following property:

<property name="wtk.emptyapi" value="your path goes here"/>
		
This property latter points to the "emptied-out" MIDP API (normally in "wtklib/emptyapi.zip") and is used for obfuscation with RetroGuard because this tool has some problems obfuscating against the normal MIDP API. This does not apply to ProGuard.

Obfuscate

The WtkObfuscate task provides a standalone obfuscation task. It uses either ProGuard or RetroGuard, depending on which of the two it finds it the WTK's bin directory or in the CLASSPATH. ProGuard is preferred, if both are found, unless the "obfuscator" attribute is specified. The task is normally not needed, since the WtkPackage task includes the same functionality. Yet, people who don't like the "all-in-one" nature of the build and packaging tasks might prefer to apply the obfuscator in a separate task.

The task provides the following parameters:

Parameter Type Required Purpose
jarfile file yes The unobfuscated source JAR file to read classes from.
jadfile file no A JAD file that accompanies the JAR file. The task uses this file to determine the list of classes to exclude from obfuscation as follows:
  • The main MIDlet classes, denoted by the MIDlet-# keys in the JAD file are preserved.
  • Classes to be loaded by name (on a Motorola phone), denoted by an iDEN-Install-Class-# keys are preserved, too.
Additional classes to spare from obfuscation can be specified using the "preserve" nested element.

If the source JAR file is overwritten (no "tojarfile" being specified), the "MIDlet-Jar-Size" key in the JAD is updated when the task is finished.

tojarfile file no The obfuscated target JAR file to create. Defaults to the source JAR file, if not specified.
bootclasspath path no The bootclasspath is needed by the obfuscator. It defaults to the MIDP API contained in ${wtk.home}/lib/midpapi.zip, or ${wtk.midpapi}, if specified. Only for RetroGuard, the emptied-out MIDP API is used.
classpath path no The classpath is needed by the obfuscator. If you use any external libraries other than the MIDP API itself, specify them here.
classpathref string no A reference to a classpath defined elsewhere.
bootclasspathref string no A reference to a bootclasspath defined elsewhere.
obfuscator String no Allows to choose between ProGuard and RetroGuard, in case both obfuscators are present. Valid arguments are "proguard" and "retroguard". If this attribute is not specified, ProGuard is always preferred over RetroGuard.
if String no Provides fine-grained control over task execution based on a property definition. The task will only be executed if the given property is defined.
unless String no Provides fine-grained control over task execution based on a property definition. The task will only be executed if the given property is not defined.
verbose boolean no Allows to set the verbosity of the task's output.

Preserve

In addition to the above parameters, the task provides one nested element "preserve" that specifies classes that should be excluded from obfuscation. This is mostly the case for classes that are loaded by name while the application is running. This nested element is supported by RetroGuard as well as ProGuard, so it's "portable". If you are looking for a means to pass obfuscator-specific arguments, have a look at the "argument" nested element below.

Parameter Type Required Purpose
class string yes The fully qualified name of a class that should be neither obfuscated nor removed (if ProGuard is used and the class is not necessary).
if String no Provides fine-grained control over the classes being preserved. The class will only be preserved if the given property is defined.
unless String no Provides fine-grained control over the classes being preserved. The class will only be preserved if the given property is not defined.

Argument

The "argument" nested element allows to pass obfuscator-specific arguments. In contrast to the general parameters of the obfuscator task and the "preserve" nested element, this one is not portable. Arguments are passed to the obfuscator verbatim. Please see the RetroGuard or ProGuard documentation for a complete list of options supported.

Parameter Type Required Purpose
value string yes/td> Specifies the argument to pass to the obfuscator.
if String no Provides fine-grained control over the arguments. The argument will only be applied if the given property is defined.
unless String no Provides fine-grained control over the arguments. The argument will only be applied if the given property is not defined.