Pack200Normalize

Description

In general packing and unpacking a JAR changes its binary representation which breaks any signature that has been used to sign the initial JAR. It is possible to "normalize" a JAR by packing and unpacking it again so that any signature applied to the "normalized" JAR will stay valid during another pack/unpack cycle. See Pack200.Packer's javadocs for more details.

This task can be used to normalize a JAR in-place or to create a new normalized JAR separate from the original JAR. The later allows you to run <jar> and <pack200normalize> in succession and the "normalization" step wouldn't do anything unless the original jar changed.

If you want to normalize the JAR in-place, you must set the force attribute to true as any file will always be up-to-date when compared to itself.

Parameters

Attribute Description Required
srcfile the file to normalize. Yes.
destfile the normalized archive. No, defaults to the srcfile.
force Whether to normalize the archive even if the destfile seems up-to-date. No, defaults to false

Parameters specified as nested elements

property

Sets a property for the packer (see the Pack200 javadocs for details).

Note this task implicitly sets the segment limit to -1.

Attribute Description Required
key Name of the property. Yes.
value Value of the property. Yes.

Examples

    <cmp:pack200normalize destfile="foo-normalized.jar"
                 xmlns:cmp="antlib:org.apache.ant.compress"
                 srcfile="foo.jar">
      <property key="pack.effort" value="9"/>
    </cmp:pack200normalize>
  

Normalizes foo.jar where foo-normalized.jar is the normalized archive. As both the normalization step and the actual packing must use the same parameters the normalization prepares for better compression results by using above than normal effort.

    <cmp:pack200normalize force="true"
                 xmlns:cmp="antlib:org.apache.ant.compress"
                 srcfile="foo.jar"/>
  

Normalizes foo.jar in-place.