Please make sure the class path is set correctly for your system.
There are three ways to configure the ProGuard task: using an external
configuration file, using embedded ProGuard configuration options, or using
the equivalent XML configuration tags. These three ways can be combined,
depending on practical circumstances and personal preference.
1. An external ProGuard configuration file
The simplest way to use the ProGuard task in an Ant build file is to keep your
ProGuard configuration file, and include it from Ant. You can include your
ProGuard configuration file by setting
the configuration
attribute of your
proguard task. Your ant build file will then look like this:
This is a convenient option if you prefer ProGuard's configuration style over
XML, if you want to keep your build file small, or if you have to share your
configuration with developers who don't use Ant.
2. Embedded ProGuard configuration options
Instead of keeping an external ProGuard configuration file, you can also copy
the contents of the file into the nested text of the proguard task
(the PCDATA area). Your Ant build file will then look like this:
<taskdef resource="proguard/ant/task.properties"
classpath="/usr/local/java/proguard/lib/proguard.jar" />
<proguard>
-libraryjars ${java.home}/lib/rt.jar
-injars in.jar
-outjars out.jar
-keepclasseswithmembers public class * {
public static void main(java.lang.String[]);
}
</proguard>
Some minor syntactical changes are required in order to conform with the XML
standard.
Firstly, the # character cannot be used for comments in an XML
file. Comments must be enclosed by an opening <!-- and a
closing -->. All occurrences of the # character
can be removed.
Secondly, the use of < and > characters would
upset the structure of the XML build file. Environment variables are now
enclosed by an opening ${ and a closing }. This
syntax also allows you to use Ant properties within the ProGuard
configuration. Other occurrences of < and >
have to be encoded as < and >.
3. XML configuration tags
If you really prefer a full-blown XML configuration, you can replace the
ProGuard configuration options by XML configuration tags. The resulting
configuration will be equivalent, but much more verbose and difficult to read,
as XML goes. The remainder of this page presents the supported tags. For a
more extensive discussion of their meaning, please consult the traditional Usage section. You can find some sample configuration
files in the examples/ant directory of the ProGuard distribution.
Print warnings about unresolved references. Use the nested
element dontwarn for more fine-grained
control. Only use this option if you know what you're doing!
Write out the entire configuration in traditional ProGuard style, to the
standard output or to the given file. Useful to replace unreadable
XML configurations.
Includes the configuration specified in the
<proguardconfiguration> task (or
<proguard> task) with the attribute id =
"ref_id". Note that only the nested elements of this configuration
are considered, not the attributes. Also note: for reading ProGuard-style
configuration files, use the configurationattribute.
The class member tags can have the following class_member_specification
attributes:
access = "access_modifiers"
The optional access modifiers of the class. Any space-separated list of
"public", "protected", "private", "static", etc., with optional negators
"!".
annotation = "annotation_name"
The optional fully qualified name of an annotation of the class member,
with optional wildcards.
type = "type"
The optional fully qualified type of the class member, with optional
wildcards. Not applicable for constructors, but required for methods for
which the parameters attribute is specified.
name = "name"
The optional name of the class member, with optional wildcards. Not
applicable for constructors.
parameters = "parameters"
The optional comma-separated list of fully qualified method parameters,
with optional wildcards. Not applicable for fields, but required for
constructors, and for methods for which the type attribute is
specified.