<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/bsf.jar</filename>
    </added>
    <added>
      <filename>src/dtd/event/bsfaction.dtd</filename>
    </added>
    <added>
      <filename>src/lib/com/izforge/izpack/event/BSFAction.java</filename>
    </added>
    <added>
      <filename>src/lib/com/izforge/izpack/event/BSFInstallerListener.java</filename>
    </added>
    <added>
      <filename>src/lib/com/izforge/izpack/event/BSFUninstallerListener.java</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -40,6 +40,15 @@
         &lt;SOURCES /&gt;
       &lt;/library&gt;
     &lt;/orderEntry&gt;
+    &lt;orderEntry type=&quot;module-library&quot;&gt;
+      &lt;library&gt;
+        &lt;CLASSES&gt;
+          &lt;root url=&quot;jar://$MODULE_DIR$/lib/bsf.jar!/&quot; /&gt;
+        &lt;/CLASSES&gt;
+        &lt;JAVADOC /&gt;
+        &lt;SOURCES /&gt;
+      &lt;/library&gt;
+    &lt;/orderEntry&gt;
   &lt;/component&gt;
 &lt;/module&gt;
 </diff>
      <filename>IzPack.iml</filename>
    </modified>
    <modified>
      <diff>@@ -845,11 +845,14 @@
     &lt;macrodef name=&quot;build-uninstaller-listener&quot;&gt;
         &lt;attribute name=&quot;name&quot;/&gt;
         &lt;attribute name=&quot;srcdir&quot; default=&quot;${src.dir}&quot;/&gt;
+        &lt;attribute name=&quot;classpath-ext&quot; description=&quot;An extension of the classpath required to build the listener&quot;
+                   default=&quot;&quot;/&gt;
         &lt;element name=&quot;uninstaller-fileset&quot;
                  implicit=&quot;yes&quot;
                  description=&quot;include and exclude elements indicating listener sources&quot;/&gt;
         &lt;sequential&gt;
-            &lt;build-listener name=&quot;@{name}&quot; srcdir=&quot;@{srcdir}&quot; izeventExcludes=&quot;**/*Installer*&quot;&gt;
+            &lt;build-listener name=&quot;@{name}&quot; srcdir=&quot;@{srcdir}&quot; izeventExcludes=&quot;**/*Installer*&quot;
+                            classpath-ext=&quot;@{classpath-ext}&quot;&gt;
                 &lt;uninstaller-fileset/&gt;
             &lt;/build-listener&gt;
         &lt;/sequential&gt;
@@ -906,6 +909,16 @@
             &lt;include name=&quot;com/coi/tools/os/izpack/COIOSHelper.java&quot;/&gt;
         &lt;/build-uninstaller-listener&gt;
 
+        &lt;build-installer-listener name=&quot;BSFInstallerListener&quot; classpath-ext=&quot;$${basedir}/lib/bsf.jar&quot;&gt;
+            &lt;include name=&quot;com/izforge/izpack/event/BSFInstallerListener.java&quot; /&gt;
+            &lt;include name=&quot;com/izforge/izpack/event/BSFAction.java&quot; /&gt;
+        &lt;/build-installer-listener&gt;
+
+        &lt;build-uninstaller-listener name=&quot;BSFUninstallerListener&quot; classpath-ext=&quot;$${basedir}/lib/bsf.jar&quot;&gt;
+            &lt;include name=&quot;com/izforge/izpack/event/BSFUninstallerListener.java&quot; /&gt;
+            &lt;include name=&quot;com/izforge/izpack/event/BSFAction.java&quot; /&gt;
+        &lt;/build-uninstaller-listener&gt;
+
         &lt;!-- CUSTOM ACTION test START
         &lt;build-compiler-listener name=&quot;ChmodCompilerListener&quot;&gt;
             &lt;include name=&quot;com/myCompany/tools/install/listener/ChmodCompilerListener.java&quot;/&gt;</diff>
      <filename>src/build.xml</filename>
    </modified>
    <modified>
      <diff>@@ -863,5 +863,455 @@ It can be changed with the subelement ``summarylogfilepath`` of the element
         &lt;/summarylogfilepath&gt;
     &lt;/info&gt;
 
+
+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:
+
+
+::
+
+    &lt;listeners&gt;
+        &lt;listener installer=&quot;BSFInstallerListener&quot;
+            uninstaller=&quot;BSFUninstallerListener&quot; /&gt;
+    &lt;/listeners&gt;
+
+
+For all referenced listeners a jar file with the same name must exist in
+``[IzPackRoot]/bin/customActions``. If compilation (packaging) fails with a
+&quot;not found&quot; error, first verify, that the jar file exists. If not, create it.
+With this custom action it is possible to perform BSF calls at installation
+and/or uninstallation time. It is not only a wrapper for a comand-line ant
+call, but also an intersected description file defining what target of the
+BSF script should be performed at what time of (un)installation and
+specifies which properties for what IzPack ``pack`` are to be used. The
+intersected description file is written as XML, the corresponding dtd is
+placed in src/dtd/event/bsfaction.dtd. The description file should be
+declared as a resource in the install.xml with the id `` BSFActionsSpec.xml``
+e.g.
+
+
+::
+
+    &lt;resources&gt;
+        ...
+        &lt;res id=&quot;BSFActionsSpec.xml&quot;
+        src=&quot;myInstallSpecs/MyBSFActionsSpec.xml&quot; /&gt;
+        ...
+    &lt;/resources&gt;
+
+
+The precise spelling of the id is important. The base path of ``src`` is the
+installation project path. If you want to use bsf, you have to specify it
+here. IzPack is designed for running without dependencies on external
+software or libraries. Therefore it is necessary to include everything
+needed, in this case ant self. The field ``&lt;jar&gt;`` in installation.xml is
+predestinated for such cases, e.g.
+
+
+::
+
+    &lt;jar src=&quot;jar/bsf/bsf.jar&quot; stage=&quot;both&quot; /&gt;
+
+
+In addition, you must also include the jar file for the language which you are
+going to use in your BSF scripts, including any additional language dependencies, e.g.
+
+::
+
+    &lt;jar src=&quot;jar/groovy/groovy-all.jar&quot; stage=&quot;both&quot; /&gt;
+
+
+Finally, if you are NOT going to embed your script content in the &quot;BSFActionsSpec.xml&quot;, but
+instead will be including it in an external resource, you must also define that resource in your
+installer.xml file (see below for an explanation)
+
+::
+
+    &lt;res id=&quot;actions.groovy&quot; src=&quot;myInstallSpecs/actions.groovy&quot; /&gt;
+
+
+
+The Basic XML Struture
+-----------------------
+
+A BSF action will be defined in the resource with the id
+&quot;BSFActionsSpec.xml&quot;. Sometimes it will help to lock into
+``[IzPackRoot]/src/dtd/event/bsfaction.dtd`` or validate a written xml file
+with the dtd.
+
+On this xml file a substitution will be performed using all defined
+``IzPack`` variables. It is performed just before processing the packs. This
+is a common way of loading spec files into custom actions. For more
+information see method ``com.izforge.izpack.util.SpecHelper.readSpec``. If
+you want to substitute some custom item, simply add a variable via
+idata.setVariable in a custom panel before ``InstallPanel``. The given
+variable name (id) should be written into the xml file in the common variable
+notation.
+
+The top level XML section is called ``&lt;bsfactions&gt;``. Only one is possible.
+The ``&lt;bsfactions&gt;`` are segregated in one or more ``&lt;pack&gt;`` elements. The
+single attribute ``&lt;name&gt;`` of the ``&lt;pack&gt;`` corresponds to the same
+structure in install.xml (for more information see also installation.dtd).
+Only the &quot;things&quot; included in the ``&lt;pack&gt;`` are performed, if a pack with
+the same name was chosen to be installed. The &quot;things&quot; to be done to self are
+defined by the element ``&lt;script&gt;``.
+
+The ``&lt;script&gt;`` takes the following attributes:
+
+-   ``language``: required. The name of the BSF language which is being used.  The
+    exact name of the language is dependent upon the BSF engine integration of that
+    particular language.  Some example values are &quot;javascript&quot; and &quot;groovy&quot;.
+
+-   ``src``: optional. The name of a resource, defined in your installer.xml, which
+    contains the script contents.  This may be used in lieu of embeddeding the script
+    contents in the BSFActionsSpec.xml file itself.
+
+In addition to the possible attributes ``&lt;script&gt;`` can contain a ``CDATA`` section
+which contains the script content, rather than using the &quot;src&quot; attibute.
+The different installer/uninstaller phases are scripted by creating a symbol definition for
+that particular phase.  The symbol will then be called by the listener (if present), and
+the appropriate phase variables defined.  If a particular phase is not defined, it will be
+skipped.
+
+NOTE:  In some languages, such as groovy and jython, you must create the function as a closure,
+so that the symbol is globally defined.  In other languages (such as beanshell), you can create
+the function normally.
+
+
+::
+
+    &lt;script language=&quot;groovy&quot; src=&quot;actions.groovy&quot; /&gt;
+
+OR
+
+::
+
+    &lt;script language=&quot;groovy&quot;&gt;&lt;![CDATA[
+      // Variables defined
+      //   idata - installer data, of type AutomatedInstallerData
+      //   npacks - # of packs selected
+      beforePacks = {
+        print &quot;before packs&quot;;
+      }
+
+      // Variables defined
+      //   idata - installer data, of type AutomatedInstallerData
+      afterPacks = {
+        print &quot;after packs&quot;;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   i - the package index
+      beforePack = {
+        print &quot;before pack &quot; + pack.name;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   i - the package index
+      afterPack = {
+        print &quot;before pack &quot; + pack.name;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   file - the dir which is to be created, of type File
+      beforeDir = {
+        print &quot;before dir &quot; + file.absolutePath;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   file - the dir which was created, of type File
+      afterDir = {
+        print &quot;after dir &quot; + file.absolutePath;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   file - the file which is to be installed, of type File
+      beforeFile = {
+        print &quot;before file &quot; + file.absolutePath;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   file - the file which was installed, of type File
+      afterFile = {
+        print &quot;after file &quot; + file.absolutePath;
+      }
+
+      // Variables defined
+      //   files - pack information, of type Pack
+      //   variables - the variables which were used during the original install, of type Properties
+      beforeDeletion = {
+        print &quot;before deletion&quot;;
+      }
+
+      // Variables defined
+      //   files - pack information, of type Pack
+      //   variables - the variables which were used during the original install, of type Properties
+      afterDeletion = {
+        print &quot;after deletion&quot;;
+      }
+
+      // Variables defined
+      //   file - the file which is to be deleted, of type File
+      //   variables - the variables which were used during the original install, of type Properties
+      beforeDelete = {
+        print &quot;before delete&quot;;
+      }
+
+      // Variables defined
+      //   file - the file which was to be deleted, of type File
+      //   variables - the variables which were used during the original install, of type Properties
+      afterDelete = {
+        print &quot;after delete&quot;;
+      }
+    ]]&gt;&lt;/script&gt;
+
+    &lt;script language=&quot;beanshell&quot;&gt;&lt;![CDATA[
+    void beforePacks() {
+        print &quot;INSTALL_PATH=${INSTALL_PATH}&quot;;
+    }
+    ]]&gt;&lt;/script&gt;
+
+
+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:
+
+
+::
+
+    &lt;listeners&gt;
+        &lt;listener installer=&quot;BSFInstallerListener&quot;
+            uninstaller=&quot;BSFUninstallerListener&quot; /&gt;
+    &lt;/listeners&gt;
+
+
+For all referenced listeners a jar file with the same name must exist in
+``[IzPackRoot]/bin/customActions``. If compilation (packaging) fails with a
+&quot;not found&quot; error, first verify, that the jar file exists. If not, create it.
+With this custom action it is possible to perform BSF calls at installation
+and/or uninstallation time. It is not only a wrapper for a comand-line ant
+call, but also an intersected description file defining what target of the
+BSF script should be performed at what time of (un)installation and
+specifies which properties for what IzPack ``pack`` are to be used. The
+intersected description file is written as XML, the corresponding dtd is
+placed in src/dtd/event/bsfaction.dtd. The description file should be
+declared as a resource in the install.xml with the id `` BSFActionsSpec.xml``
+e.g.
+
+
+::
+
+    &lt;resources&gt;
+        ...
+        &lt;res id=&quot;BSFActionsSpec.xml&quot;
+        src=&quot;myInstallSpecs/MyBSFActionsSpec.xml&quot; /&gt;
+        ...
+    &lt;/resources&gt;
+
+
+The precise spelling of the id is important. The base path of ``src`` is the
+installation project path. If you want to use bsf, you have to specify it
+here. IzPack is designed for running without dependencies on external
+software or libraries. Therefore it is necessary to include everything
+needed, in this case ant self. The field ``&lt;jar&gt;`` in installation.xml is
+predestinated for such cases, e.g.
+
+
+::
+
+    &lt;jar src=&quot;jar/bsf/bsf.jar&quot; stage=&quot;both&quot; /&gt;
+
+
+In addition, you must also include the jar file for the language which you are
+going to use in your BSF scripts, including any additional language dependencies, e.g.
+
+::
+
+    &lt;jar src=&quot;jar/groovy/groovy-all.jar&quot; stage=&quot;both&quot; /&gt;
+
+
+Finally, if you are NOT going to embed your script content in the &quot;BSFActionsSpec.xml&quot;, but
+instead will be including it in an external resource, you must also define that resource in your
+installer.xml file (see below for an explanation)
+
+::
+
+    &lt;res id=&quot;actions.groovy&quot; src=&quot;myInstallSpecs/actions.groovy&quot; /&gt;
+
+
+
+The Basic XML Struture
+-----------------------
+
+A BSF action will be defined in the resource with the id
+&quot;BSFActionsSpec.xml&quot;. Sometimes it will help to lock into
+``[IzPackRoot]/src/dtd/event/bsfaction.dtd`` or validate a written xml file
+with the dtd.
+
+On this xml file a substitution will be performed using all defined
+``IzPack`` variables. It is performed just before processing the packs. This
+is a common way of loading spec files into custom actions. For more
+information see method ``com.izforge.izpack.util.SpecHelper.readSpec``. If
+you want to substitute some custom item, simply add a variable via
+idata.setVariable in a custom panel before ``InstallPanel``. The given
+variable name (id) should be written into the xml file in the common variable
+notation.
+
+The top level XML section is called ``&lt;bsfactions&gt;``. Only one is possible.
+The ``&lt;bsfactions&gt;`` are segregated in one or more ``&lt;pack&gt;`` elements. The
+single attribute ``&lt;name&gt;`` of the ``&lt;pack&gt;`` corresponds to the same
+structure in install.xml (for more information see also installation.dtd).
+Only the &quot;things&quot; included in the ``&lt;pack&gt;`` are performed, if a pack with
+the same name was chosen to be installed. The &quot;things&quot; to be done to self are
+defined by the element ``&lt;script&gt;``.
+
+The ``&lt;script&gt;`` takes the following attributes:
+
+-   ``language``: required. The name of the BSF language which is being used.  The
+    exact name of the language is dependent upon the BSF engine integration of that
+    particular language.  Some example values are &quot;javascript&quot; and &quot;groovy&quot;.
+
+-   ``src``: optional. The name of a resource, defined in your installer.xml, which
+    contains the script contents.  This may be used in lieu of embeddeding the script
+    contents in the BSFActionsSpec.xml file itself.
+
+In addition to the possible attributes ``&lt;script&gt;`` can contain a ``CDATA`` section
+which contains the script content, rather than using the &quot;src&quot; attibute.
+The different installer/uninstaller phases are scripted by creating a symbol definition for
+that particular phase.  The symbol will then be called by the listener (if present), and
+the appropriate phase variables defined.  If a particular phase is not defined, it will be
+skipped.
+
+NOTE:  In some languages, such as groovy and jython, you must create the function as a closure,
+so that the symbol is globally defined.  In other languages (such as beanshell), you can create
+the function normally.
+
+
+::
+
+    &lt;script language=&quot;groovy&quot; src=&quot;actions.groovy&quot; /&gt;
+
+OR
+
+::
+
+    &lt;script language=&quot;groovy&quot;&gt;&lt;![CDATA[
+      // Variables defined
+      //   idata - installer data, of type AutomatedInstallerData
+      //   npacks - # of packs selected
+      beforePacks = {
+        print &quot;before packs&quot;;
+      }
+
+      // Variables defined
+      //   idata - installer data, of type AutomatedInstallerData
+      afterPacks = {
+        print &quot;after packs&quot;;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   i - the package index
+      beforePack = {
+        print &quot;before pack &quot; + pack.name;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   i - the package index
+      afterPack = {
+        print &quot;before pack &quot; + pack.name;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   file - the dir which is to be created, of type File
+      beforeDir = {
+        print &quot;before dir &quot; + file.absolutePath;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   file - the dir which was created, of type File
+      afterDir = {
+        print &quot;after dir &quot; + file.absolutePath;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   file - the file which is to be installed, of type File
+      beforeFile = {
+        print &quot;before file &quot; + file.absolutePath;
+      }
+
+      // Variables defined
+      //   pack - pack information, of type Pack
+      //   file - the file which was installed, of type File
+      afterFile = {
+        print &quot;after file &quot; + file.absolutePath;
+      }
+
+      // Variables defined
+      //   files - pack information, of type Pack
+      //   variables - the variables which were used during the original install, of type Properties
+      beforeDeletion = {
+        print &quot;before deletion&quot;;
+      }
+
+      // Variables defined
+      //   files - pack information, of type Pack
+      //   variables - the variables which were used during the original install, of type Properties
+      afterDeletion = {
+        print &quot;after deletion&quot;;
+      }
+
+      // Variables defined
+      //   file - the file which is to be deleted, of type File
+      //   variables - the variables which were used during the original install, of type Properties
+      beforeDelete = {
+        print &quot;before delete&quot;;
+      }
+
+      // Variables defined
+      //   file - the file which was to be deleted, of type File
+      //   variables - the variables which were used during the original install, of type Properties
+      afterDelete = {
+        print &quot;after delete&quot;;
+      }
+    ]]&gt;&lt;/script&gt;
+
+    &lt;script language=&quot;beanshell&quot;&gt;&lt;![CDATA[
+    void beforePacks() {
+        print &quot;INSTALL_PATH=${INSTALL_PATH}&quot;;
+    }
+    ]]&gt;&lt;/script&gt;
+
+
+More detailed examples can be downloaded from http://jira.codehaus.org/secure/attachment/39246/sample.tar.gz
+and http://jira.codehaus.org/secure/attachment/39379/sample2.tar.gz
+
 .. include:: include-bottom.inc
 </diff>
      <filename>src/doc-reST/custom-actions.txt</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4cefadc07d0119445e3e4a401c755666ca0f46b9</id>
    </parent>
  </parents>
  <author>
    <name>jponge</name>
    <email>jponge@7d736ef5-cfd4-0310-9c9a-b52d5c14b761</email>
  </author>
  <url>http://github.com/jponge/izpack/commit/d2c3abca8df07f36dd722bc9586a2c032f25f61b</url>
  <id>d2c3abca8df07f36dd722bc9586a2c032f25f61b</id>
  <committed-date>2009-01-24T06:02:42-08:00</committed-date>
  <authored-date>2009-01-24T06:02:42-08:00</authored-date>
  <message>IZPACK-240: support of scripting languages for handling event using the Bean Scripting Framework (Apache BSF). Original patch contributed by Matthew Inger.

git-svn-id: https://svn.codehaus.org/izpack/izpack-src/trunk@2505 7d736ef5-cfd4-0310-9c9a-b52d5c14b761</message>
  <tree>077a6911709132961453aa33661f875bb04ea0d2</tree>
  <committer>
    <name>jponge</name>
    <email>jponge@7d736ef5-cfd4-0310-9c9a-b52d5c14b761</email>
  </committer>
</commit>
