Packs a jar to Packed file or a compressed packed file, as well as repack a file, typically for jarsigning.
Attribute | Description | Required |
src |
file name of the input jar to be packed, must
have extension ".jar" |
Yes |
destfile |
file name of the output file, extensions, ".pack
or .pac" |
Yes |
gzipoutput |
specifies the file should be compressed using
value "true, false", cannot be used with repack, the destfile must have
an extension ".pack.gz, pac.gz". |
No |
verbose |
specify a numeric value for the verbosity values
range from 0 to 9. |
No |
modificationtime |
generic modification time for the entries with
in a jar, string "keep, latest". |
No |
stripdebug |
strips Java Class attributes not required for runtime a value of "true, false". | No |
deflatehint |
deflate hint for the jar entries when the packed
file is unpacked, "keep, true, false" |
No |
keepfileorder |
specifies whether the ordering of the entries
should be maintained upon unpacking, string "true, false". |
No |
unknownattribute |
action to be taken when an unknown java attribute is encountered by the packer, string "strip, error, pass" | No |
segmentlimit |
the file sizes (numerical value)
to consider for each segment in a packed files. |
No |
effort |
the packing effort a numerical
value ranging from 1 to 9. |
No |
configfile |
used to set other options, by
creating a properties file and specifying it here. |
No |
Either gzipout or repack must be used, but not both.
Attribute | Description | Required |
src |
file name of the input packed stream, the extension must be ".pack, pac, .gz" | Yes |
destfile |
file name of the output JAR file, extensions,
".jar" |
Yes |
verbose |
specify a numeric value for the verbosity values
range from 0 to 9. |
No |
In order to use this, download the Pack200Task.jar to some location
of your choice <install>/Pack200Task.jar.
In the build.xml create the Task for example:
<!-- Create our Pack200 Tasks -->
<target name="p200">
<!-- Create our packer task -->
<taskdef name="pack200"
classname="com.sun.tools.apache.ant.pack200.Pack200Task"
classpath="<install>/Pack200Task.jar"/>
<!-- Create our unpacker task -->
<taskdef name="unpack200"
classname="com.sun.tools.apache.ant.pack200.Unpack200Task"
classpath="${dist}/Pack200Task.jar"/>
</target>
and you are ready to go.....
Here is a simple example to pack and unpack a jar.
<target name="simple" depends="p200">
<pack200 src="${test}/Test.jar"
destfile="${test}/testout.pack.gz"/>
<unpack200 src="${test}/testout.pack.gz"
dest="${test}/foo.jar"/>
</target>To repack a file for signing, the above example also accomplishes the same.
<target name="simple2" depends="p200">
<pack200 src="${test}/Test.jar"
destfile="${test}/testout.jar
repack="true"/>
</target>
<target name="complex" depends="p200">
<delete file="${test}/testout.pack"/>
<pack200 src="${test}/Test.jar"
destfile="${test}/testout.pack"
zipoutput="false"
verbose="1"
modificationtime="latest"
deflatehint="false"
unknownattribute="error"
<unpack200 src="${test}/testout.pack"
dest="${test}/foobar.jar"/>
</target>
<target name="complex2" depends="p200">
<!-- Create a configuration file -->
<echo file="${test}/pack.conf" append="false">pack.modification.time=latest
pack.deflate.hint=false
pack.unknown.attribute=error
</echo>
<pack200 src="${test}/Test.jar"
destfile="${test}/testout.pack"
configfile="${test}/pack.conf"
verbose="1"/>
<unpack200 src="${test}/testout.pack"
dest="${test}/foobar.jar"/>
</target>
Sun Copyright ???