Issue Details (XML | Word | Printable)

Key: IZPACK-240
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Julien Ponge
Reporter: Matthew Inger
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
IzPack

Submission of BSF Scripting Feature

Created: 05/Jan/09 10:20 AM   Updated: 20/Apr/09 03:26 AM   Resolved: 24/Jan/09 08:03 AM
Return to search
Component/s: Installer
Affects Version/s: 4.2.0
Fix Version/s: 4.3.0

Time Tracking:
Not Specified

File Attachments: 1. File bsf-jp.diff (38 kB)
2. File bsf-listener.diff (35 kB)
3. Java Archive File bsf.jar (111 kB)
4. GZip Archive sample.tar.gz (3.08 MB)
5. GZip Archive sample2.tar.gz (414 kB)


Patch Submitted: Yes


 Description  « Hide

This feature enables the use of any BSF 2.4 supported language as a way to script install and uninstall events. Attached is the SVN patch file and bsf.jar file (version 2.4.0 of bsf) which should be placed in the "lib" directory.

The patch file contains the new source code, as well as the build.xml modifications necessary to build the new listeners.

I'm still trying to figure out how the documentation is generated, so i can add that. Any help would be appreciated.



Matthew Inger added a comment - 05/Jan/09 10:58 AM

Updating with documentation (I can't compile the docs on my side, so I hope i got everything formatted correctly).


Matthew Inger made changes - 05/Jan/09 10:58 AM
Field Original Value New Value
Attachment bsf-listener.diff [ 39172 ]
Matthew Inger made changes - 05/Jan/09 10:58 AM
Attachment bsf-listener.diff [ 39170 ]
Matthew Inger added a comment - 05/Jan/09 10:59 AM

Any help in how to write test cases for this would be appreciated. Thanks.


Julien Ponge made changes - 05/Jan/09 11:39 AM
Assignee Julien Ponge [ jponge ]
Dan Tran added a comment - 08/Jan/09 11:08 AM

do you have minimal izpack's descriptor ( ie install.xml) include all necessary dependencies beside izpack compiler to demonstrate this feature? I can help using izpack-maven-plugin to create some sort integration test.


Matthew Inger added a comment - 08/Jan/09 12:00 PM

Attached is a quick and dirty sample project which just installs a single file README.txt, and issues some print statements during the various installer phases.

You should set he environment variable IZPACK_HOME to the your izpack installation. It's expected that the file lib/standalone-compiler will have the new BSF listeners in them. Then you can just run ant to build the sample installer.


Matthew Inger made changes - 08/Jan/09 12:00 PM
Attachment sample.tar.gz [ 39246 ]
Matthew Inger added a comment - 08/Jan/09 12:02 PM

Note the sample assumes you're going to use groovy as your scripting language. You could just as easily use Rhino, JRuby, Jython, or any other bsf supported language.

Of course, you'd have to include those jars in the installer.xml, and also alter the BSFActions.xml to name the correct language, and have valid code for that language.


Matthew Inger added a comment - 08/Jan/09 12:27 PM

PS: I've also tried this out with jython as well, just to be safe, and included the jython.jar file produced by running the jython installer, and selecting the standalone installation. Then my script entry in BSFActionsSpec.xml looks as follows:

<script language="jython"><![CDATA[
def beforePacks():
print "(jython) INSTALL_PATH=" , idata.getVariable("INSTALL_PATH")
return
]]></script>

So all seems to be well with the BSF integration as a whole. I don't seem to have done anything specific to groovy, although that's the only language I've been using with this.


Julien Ponge added a comment - 11/Jan/09 09:10 AM

On the feature: pluging scripts to handle events would be a nice addition.

On the implementation:

  • Actions code is put in an XML document. I personaly would prefer to have them in a file of the target language (e.g., foo.rb for a Ruby file). Is there any way you could rework the solution to make that possible?
  • Documentation of the change is great.
  • The new files (e.g., BSFUninstallerListener.java) need to have our common license header.
  • Please wipe the $Id$ marker in the DTD, as it is always a mess with version control and merges
  • The addition of the BSF jar does not seem intrusive. Someone to confirm?

On the provided sample: it's a nice one, but it would be better if we had a smaller one for bundling with IzPack (that's many big jars to include!).

Verdict: I am in favor of merging this if other developers agree, and if the above points are adressed by an updated patch.


Matthew Inger added a comment - 16/Jan/09 10:05 AM

To your points:

1. I had thought about this, but the issue I ran into was two fold:
a. How do I ensure those external files gets packed in with the installer, and then how do I manage to find and run them
without having to have to unpack them into the installed application directory?
b. Same for the uninstaller

also, I personally prefer to include the scripts inline, though I am tpically not working with a large amount of packages, and my
scripts are typically for doing things like backing up files, cleaning up exploded webapps, etc....

At the worst, I would like to give the option to have the scripts inline or in an external resource.

2. Thanks

3. I can take the header from other files

4. No problem

5. I definately found that inclusion of the bsf and commons-logging jar did not add much to the installer size. The actual language
implementatiosn themselves (groovy, jython, etc...) are typically the space eaters.

Perhaps we can use a javascript example instead, as the rhino jar is only about 700K, compared to the ~2.3MB of groovy or ~1.9MB of jython.

If you could help out with item #1, at least in terms of some pointers, I can definately take care of the other solutions with no issues.


Matthew Inger added a comment - 16/Jan/09 10:11 AM

BSF Listener changes


Matthew Inger made changes - 16/Jan/09 10:11 AM
Attachment bsf-listener.diff [ 39372 ]
Matthew Inger made changes - 16/Jan/09 10:12 AM
Attachment bsf-listener.diff [ 39172 ]
Matthew Inger added a comment - 16/Jan/09 10:14 AM

I have added the appropriate headers to the java files and wiped out the $Id$ marker in the dtd. The diff file has been replaced to address this.

I will work on a beanshell oriented framework, as it has a very small footprint (275K).


Matthew Inger added a comment - 16/Jan/09 11:08 AM

Fixing some issues with Beanshell integration, allow us to specify different ways to check for method existence in different scripting languages.


Matthew Inger made changes - 16/Jan/09 11:08 AM
Attachment bsf-listener.diff [ 39373 ]
Matthew Inger made changes - 16/Jan/09 11:09 AM
Attachment bsf-listener.diff [ 39372 ]
Matthew Inger added a comment - 16/Jan/09 11:21 AM

Smaller sample which uses Beanshell for the scripting language, which makes it very lightweight in terms of the disk space used for the sample.


Matthew Inger made changes - 16/Jan/09 11:21 AM
Attachment sample2.tar.gz [ 39374 ]
Matthew Inger made changes - 16/Jan/09 11:46 AM
Attachment bsf-listener.diff [ 39373 ]
Matthew Inger made changes - 16/Jan/09 11:46 AM
Attachment sample2.tar.gz [ 39374 ]
Matthew Inger added a comment - 16/Jan/09 11:47 AM

Adding in the ability to have a script as an external resource, or as embedded content.


Matthew Inger made changes - 16/Jan/09 11:47 AM
Attachment sample2.tar.gz [ 39376 ]
Attachment bsf-listener.diff [ 39375 ]
Matthew Inger added a comment - 16/Jan/09 12:09 PM

I've added the ability to have a script be a resource name instead of just embedded content:

<script language="beanshell" src="actions.bsh" />

instead of

<script language="beanshell"><![CDATA[ ... ]]></script>

The caveat is that you have to include it as a resource in your installer.xml, and it will not
be parsed for variable subsitutions, whereas an embedded script would be:

<res id="actions.bsh" src="actions.bsh"/>

External scripts are still parsed for variable replacement though.


Matthew Inger made changes - 16/Jan/09 12:09 PM
Attachment sample2.tar.gz [ 39379 ]
Attachment bsf-listener.diff [ 39378 ]
Matthew Inger made changes - 16/Jan/09 12:09 PM
Attachment bsf-listener.diff [ 39375 ]
Matthew Inger made changes - 16/Jan/09 12:09 PM
Attachment sample2.tar.gz [ 39376 ]
Matthew Inger added a comment - 16/Jan/09 12:16 PM

a correction to the previous comment, in that external resources WILL BE PARSED for variable subsitutions.


Julien Ponge added a comment - 18/Jan/09 03:18 PM

In BSFInstallerListener, there are a bunch of "params" maps that are never used...

Did you miss something, or can it be removed?


Julien Ponge added a comment - 18/Jan/09 03:26 PM

Reworked patch.


Julien Ponge made changes - 18/Jan/09 03:26 PM
Attachment bsf-jp.diff [ 39411 ]
Julien Ponge added a comment - 18/Jan/09 03:28 PM

I have uploaded a reworked patch.

I would need your review Matthew, as well as a clarification on the "useless" params maps in BSFInstallerListener.


Matthew Inger added a comment - 18/Jan/09 08:29 PM

I will try to take a look at your changes, and the parameters within a day or two. I know the "variables" map is used to pass over to the uninstaller, since the uninstaller doesn't seem to have access to the "AutomatedInstallData" object, so had to add the variables as a seperate map in the uninstall action. (which also presents an interesting situation, in that the AutomatedInstallData object is not even packaged up with the uninstaller program.


Matthew Inger added a comment - 21/Jan/09 12:11 PM

Yes, I agree the "params" maps are useless. They may have been left over from something I was thinking about doing at one point, and can be safely removed.

I guess it woould be helpful if you outlined what you changed, as it will make it much easier for me to evaluate the changes.


Julien Ponge added a comment - 22/Jan/09 01:49 AM

Actually I made some really minor changes:

  • documentation formating so that it is ok w.r.t. the reST format
  • added generics on collections
  • simplified a boolean expression or two
  • ... and that should be it

Cheers


Matthew Inger added a comment - 22/Jan/09 08:56 PM

Sounds good to me.


Julien Ponge added a comment - 24/Jan/09 08:03 AM

It's in!

Thanks a lot Matthew for your work.


Julien Ponge made changes - 24/Jan/09 08:03 AM
Resolution Fixed [ 1 ]
Fix Version/s 4.3.0 [ 14763 ]
Status Open [ 1 ] Resolved [ 5 ]
Matthew Inger added a comment - 24/Jan/09 10:43 AM

No problem. Nice to have it part of the standard izpack now instead of being a custom addition


Julien Ponge made changes - 20/Apr/09 03:26 AM
Status Resolved [ 5 ] Closed [ 6 ]