We need you!

Icon

The IzPack documentation needs work, and you are invited to edit it!

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Custom Actions

(by Klaus BARTZ)

Table of Contents

Overview

The implementation of custom actions presume knowledge of java. Custom actions are not a good starting point for learning java. Learners can use existent custom actions but should not implement them as exercise.

...

  • Implement com.izforge.izpack.event.CompilerListener or extend com.izforge.izpack.event.SimpleCompilerListener. Place it as IzPackRoot/src/lib/MyPackagePath/MyCompilerListener.java.
  • Add a "build-compiler-listener" macro call in to the build.listeners target in IzPackRoot/src/build.xml. Note that the name attribute value in the build-instealler-listener must match CompilerListenerimplementation class name (not including the package). You should include the actual Listener implementation, as well as any other classes required by the listener.

    Code Block
    <build-compiler-listener
    name="MyCompilerListener">
        <include
        name="[MyPackagePath]/MyCompilerListener.java"/>
        <include
        name="[MyPackagePath]/SomeOtherHelperClass.java"/>
    </build-compiler-listener>
  • Run IzPackRoot/src/build.xml. An ant alone will execute the required targets.
  • Add a "listeners" ELEMENT with a "listener" ELEMENT with a "compiler" attribute in to MyProjectPath/install.xml

    Code Block
    <listeners>
      <listener compiler="MyCompilerListener" />
    <listeners>
  • Compile with the following command, or an ant task you have set up.

    Code Block
    java -jar [IzPackRoot]/lib/compiler.jar -HOME [IzPackRoot]
      [MyProjectPath]/install.xml -b [MyProductPath] -o
      [MyBuildPath]/install.jar
  • Test it

...

  • Copy the files to IzPackRoot/src/lib/com/myCompany/tools/install/listener
  • In IzPackRoot/src/build.xmlthere are the lines

    Code Block
    <!-- CUSTOM ACTION test START
    CUSTOM ACTION test END -->

    Uncomment them (activate the lines between them).

  • Build IzPack new.
  • Compile a test installation with

    Code Block
    java -jar [IzPackRoot]/lib/compiler.jar -HOME [IzPackRoot]
      [IzPackRoot]/sample/listener/install.xml
      -b [IzPackRoot]/sample/listener -o
      [IzPackRoot]/sample/listener/install.jar
  • Install it

    Code Block
    java -jar install.jar

...

Code Block
<info>
    ...
    <summarylogfilepath>
        $INSTALL_PATH/Uninstaller/MySummary.htm
    </summarylogfilepath>
</info>

BSF (Bean Scripting Framework) Actions (InstallerListener and UninstallerListener)

...

In this section the BSF 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 BSF related custom actions BSFInstallerListener and BSFUninstallerListener. As recapitulation, to add any custom action a reference in install.xml will be needed, as example:

...

Code Block
<res id="actions.groovy" src="myInstallSpecs/actions.groovy" />

The Basic XML Struture

...

A BSF action will be defined in the resource with the id "BSFActionsSpec.xml". Sometimes it will help to lock into IzPackRoot/src/dtd/event/bsfaction.dtd or validate a written xml file with the dtd.

...