Pages

Tuesday, May 25, 2010

Create Shortcut Specification for IzPack

In IzPack software, operating system specific shortcut specification must be provided along with the common configuration specification to support the shortcuts. This is caused by the OS specific nature of shortcuts’ operation. In other, words today we will discuss how to write the shortcutSpec.xml that is required to accommodate shortcuts in the Windows environment.
Platform: Windows
File Name: shortcutSpec.xml
The root element of this xml document is <shortcuts>.This xml document has 3 other important sub elements under this tag. they are <skipIfNotSupported/>, <programGroup/> and <defaultCurrentUser/>. <skipIfNotSupported/> allows the panel to be silent on a non-supporting system. <defaultCurrentUser/> allows the “current user” to be the default selection for the panel. If this element is not present, the default selection is “all users”. <programGroup/> allows to specify the name of the menu under which shortcuts to be specified.
<skipIfNotSupported/>
<programGroup defaultName="Jefe" location="applications"/>
After these 3 elements, comes the most important functionality providers of the specification. <shortcut> tags each per shortcut, will provides the OS specific details to the installer to create the shortcuts.
Given below is the code for a shortcut to execute a startup.bat of a Tomcat bundle. This will create a desktop shortcut specified by desktop="yes" attribute and a shortcut in the program group specified by programGroup="yes" attribute, under the name Jefe which is defined in <programGroup> tag. In this shortcut configuration data name of the shortcut appears as Jefe – Startup and the required bat file to execute is located in the path given in the target attribute. While name and target attributes are essential to be specified in a short cut, all other attributes are optional. workingDirectory specify the folder in which the startup.bat is located.  iconFile will specify the location and the name of the icon to use for this shortcut, which will appear in both desktop and the program group. description attribute will give a brief description about the shortcut when it is been requested. initialState=”noShow” will hide command prompt opening when bat files are requested to execute. Since I need to monitor the command prompt information at startup of the Tomcat I used the initialState as “normal”. Even though all the attributes expect name and the target are considered optional, programGroup, desktop, startMenu and startup are considered as semi-optional attributes. There value is either yes or no. Any other value other than these two are interpreted as no. createForPack another important child element of shortcut. It will specify under which pack this shortcut is installed. If this pack is not selected while installation, the respective shortcut is omitted automatically.
<shortcut
        name="Jefe - Startup"
        target="$INSTALL_PATH\core\liferay-portal-5.2.3\tomcat-6.0.18\bin\startup.bat"
        commandLine=""
        workingDirectory="$INSTALL_PATH\core\liferay-portal-5.2.3\tomcat-6.0.18\bin"
        description="Jefe Server Startup"
        iconFile="$INSTALL_PATH\images\startup.ico"
        iconIndex="0"
        initialState="normal"
        programGroup="yes"
        desktop="yes"
        applications="no"
        startMenu="no"
        startup="no">

       <createForPack name="core"/>
</shortcut>
Similarly I have created another shortcut to execute the shutdown.bat in the same folder to shutdown the Tomcat server. I’ll not discuss this since it is just a replacement for the word startup by shutdown. Now let’s take a look on how to create a shortcut to execute the uninstall.jar created by the IzPack installer for the Jefe installer.
<shortcut
        name="Jefe - Uninstaller"
        target="$INSTALL_PATH\uninstaller\uninstall.bat"
        commandLine=""
        workingDirectory="$INSTALL_PATH\uninstaller"
        description="Jefe Server will be completely Uninstalled"
        iconFile="$INSTALL_PATH\images\uninstall.ico"
        iconIndex="0"
        initialState="noShow"
        programGroup="yes"
        desktop="no"
        applications="no"
        startMenu="no"
        startup="no">

       <createForPack name="core"/>
</shortcut>
The difference in this shortcut to the one discussed earlier is that we are using a a bat file given below to execute the jar file and has configured following 2 attributes differently to how they were configured previously. initialState=”noShow” and desktop=”no”. The bat file I’m using for this operation is as given bellow,
@Echo Uninstalling…
java –jar uninstall.jar
@Echo Successfully Uninstalled
The full description of the different attributes are given in the IzPack manual under Desktop Shortcuts section. The same shortcuts created for the Unix base system in also given as an example in the IzPack manual under the sub section A simple shortcut specification for Unix under the Section Desktop Shortcuts.

No comments:

Post a Comment