Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Ant

...

Actions Installer/Uninstaller Listener

In this section the common ant task custom actions are described in detail. It is only for developers who are not acquainted with IzPack or it's custom actions. In addition to the basics there are some recapitulations of the common custom action techniques and some hints for pitfalls. In the package com.izforge.izpack.event there are the ant related custom actions AntActionInstallerListener and AntActionUninstallerListener. As recapitulation, to add any custom action a reference in install.xml will be needed, as example:

...

Be aware, that an "extended" ant use needs more than one jar, for example often xercesImpl.jar. If an obscure "class not found" exception is raised during testing, check first for missing jar files. For supporting uninstallation the jar field was extended by the attribute stage. If an ant uninstaller custom action is used, the uninstaller also needs the jar files. If stage is "both" or "uninstall", the contents of the referenced jar file will be packed into uninstaller.jar. Be aware that not the jar file itself, but the contents of it are required. This implies, that the paths of the contained files are unique and the information in meta-inf/Manifest.mf will be lost.

The AntActionSpec XML Struture

An ant action will be defined in the resource with the id "AntActionsSpec.xml". Sometimes it will help to look into createpage.action?spaceKey=IZPACK&title=IzPackRoot&linkCreation=true&fromPageId=142803064antaction.dtd (4.x SVN trunk) or validate a written xml file with the dtd.

...

The following outlines the sections available in the AntActionsSpec.xml:

antactions

The top level XML section is called <antactions>. The antactions element may contain zero or more pack elements described below:

pack

The pack element is used to tie the action(s) to be performed to the packs selected in the installation. The pack element may have the following attribute:

...

The pack element must contain 1 or more antcall elements.

antcall

The antcall element has the following attributes:

...

In addition to the possible attributes there are some elements may be defined within an antcall element. All elements can be defined zero or more times in an <antcall>. Although all elements are optional, no ANT tasks will be performed unless a <target> element is specified. Do not confuse the following: "required"s are related to the attributes of the elements, not to the elements themselfs.

property

Defines a property to be used with all targets and uninstall_targets which are defined for this antcall.  The following attributes may be defined:

Name

Required

Description

Allowed Values

name

yes

The name of the property to set.

Any string value

value

yes

The value to set for the property.

Any string value

propertyfile

Defines properties to be used, read from a property file which are defined for this antcall.  The following attributes may be defined:

...

One way to fill specific data into it is to create a new file in a custom panel and fill it with values given by input fields. The file path can be set at installation time, if there is a variable in AntActionSpec.xml and an IzPack variable was defined before InstallPanel. That file can be only created with deleteOnExit, if no <uninstall_target> was defined in this <antcall>. This implies, that other <antcall>}}s can have a {{<uninstall_target>. <target>: target to call at installation h3. Targets to perform with this antcall at installation time. The targets should be defined in the given buildfile or else an ant exception will be raised. This is that what you use, if you don't want to perform the default target. e.g. cleaning the IzPack project with ant clean.

target

The target to execute in the ANT build file during action specified in the order attribute of the antcall (install time).  Note: Multiple targets to execute for the action may be specified by using multiple target elements.  The following attribute must be defined:

Name

Required

Description

Allowed Values

name

yes

Name of the target to execute in the ANT buildfile

Any valid ANT target defined in the build file.

uninstall_target

Targets to perform with this antcall at uninstallation time. Note: Multiple targets to execute for the action may be specified by using multiple target elements.

...