[izpack-users] Feature Request - Scripting Languages for custom actions

Matthew Inger mattinger at gmail.com
Mon Jan 7 21:25:47 CET 2008


I do actually have a version, where I can define all of the installer
listener methods in a groovy script
(i've tested it when it's embedded in the BSFActionsSpec.xml file, but
haven't tested it yet externally).
It requires changes to the build file, and inclusion of the BSF,
commons-logging (required by bsf), and
groovy-all jar files.

The changes to the build file are not limited strictly to just adding the
macro calls to build the installer and
uninstaller listener jars.  The uninstaller listener macro needs to have the
ability to have the classpath given to it
as well (which only the installer listener macro has right now).

I've create a .tar.gz file which has the appropriate jar files, new
build.xml and source files.  This can be
extracted into the root of the IzPack source tree, and then you can build as
normal.

I did not include the groovy-all.jar file, as it's not necessary for compile
and packaging.  It's only a runtime
requirement if you want to use groovy as your scripting language.

Please let me know what you think.

installer.xml snippet:
----------------------------------
<jar src="bsf.jar" />
<jar src="commons-logging-1.1.jar" />
<jar src="groovy-all.jar" />

<listener installer="BSFInstallerListener"
uninstaller="BSFUninstallerListener" />

<resources>
   <res id="BSFActionsSpec.xml" src="BSFActionsSpec.xml" />
</resources>

BSFActionsSpec.xml
------------------------------------
<bsfactions>
  <pack name="pack1">
    <script language="groovy"><![CDATA[
      beforePacks = {
        print "beforePacks(" + idata + "," + npacks + "," + handler + ")";
        print "\n";
      }
      afterPacks = {
        print "afterPacks(" + idata + "," + handler + ")";
        print "\n";
      }
      beforePack = {
        print "beforePack(" + pack + "," + i + "," + handler + ")";
        print "\n";
      }
      afterPack = {
        print "afterPack(" + pack + "," + i + "," + handler + ")";
        print "\n";
      }
      beforeDir = {
        print "beforeDir(" + file + "," + pack + ")";
        print "\n";
      }
      afterDir = {
        print "afterDir(" + file + "," + pack + ")";
        print "\n";
      }
      beforeFile = {
        print "beforeFile(" + file + "," + pack + ")";
        print "\n";
      }
      afterFile = {
        print "afterFile(" + file + "," + pack + ")";
        print "\n";
      }
    ]]></script>
  </pack>
</bsfactions>


On Jan 4, 2008 3:29 PM, Matthew Inger <mattinger at gmail.com> wrote:

> I don't really need "tight" integration.  I just need to declare anonymous
> functions and assign them
> to variable references.  There will be no function parameters per-se.
> Rather, there will be well defined
> variable names which will contain the parameters.
>
> For instance, for the "beforeFile" and "afterFile" methods, the variables
> "file" and "pack" would be defined,
> and the function would refer to those variables (as opposed to the java
> approach of passing them as function
> parameters).
>
> The groovy specific implementation I had been working on actually passed
> things as parameters.  But this was
> possible because I could compile the script to a java class, instantiate
> it, and invoke methods on it.  BSF does not
> have that capability (as the groovy api, or the jsr 223 interfaces do)
> that I can tell.
>
> Does anyone see any downside to doing it with anonymous functions as I
> have suggested above?
>
>
>
> On Jan 4, 2008 2:51 PM, Julien Ponge <julien.ponge at gmail.com> wrote:
>
> > I've played with BSF before and that's a good bet if you want to plug
> > any scripting language. The downside is that sometimes you'd better
> > turn to the API of your scripting language if you need tighter
> > integration with it.
> > _______________________________________________
> > izpack-users mailing list
> > izpack-users at lists.berlios.de
> > https://lists.berlios.de/mailman/listinfo/izpack-users
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.berlios.de/pipermail/izpack-users/attachments/20080107/2900a723/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bsf-integration.tar.gz
Type: application/x-gzip
Size: 165667 bytes
Desc: not available
Url : https://lists.berlios.de/pipermail/izpack-users/attachments/20080107/2900a723/attachment-0001.gz 


More information about the izpack-users mailing list