Sap
Sap

Reputation: 5291

Izpack simple installation just to copy files

I am trying to make a very simplistic installer using IzPack. It should do the following two things 1. Copy and paste all the content of dist directory to UserHome/MyApp dir. 2. Execute a batch file to edit registry entry to start the jar file on user logon.

But I am stuck at the first step only! nothing is installed if I use the following XML and generate the installer. Generated installer runs and does show the InstallPanel but nothing is copied to the user_home directory.

From what it seems like I am not able to assign value to Install_path variable.

 <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
    <installation version="1.0">
        <variables>
            <variable name="INSTALL_PATH" value="$USER_HOME/MyApp"/>
        </variables>
        <info>
            <appname>My App</appname>
            <appversion>1.0</appversion>
            <authors>
                <author name="My APP Author" email="[email protected]"/>
            </authors>
            <url>http://SomeURL.net</url>
        </info>
          <guiprefs width="640" height="480" resizable="yes"/>
        <locale>
            <langpack iso3="eng"/>
        </locale>
        <panels>
            <panel classname="InstallPanel"/>
        </panels>
        <packs>
            <pack name="Base" required="yes">
                <description>The base files</description>
                <fileset dir="dist" targetdir="$INSTALL_PATH"/>
            </pack>
        </packs>
    </installation>

UPDATE

   <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<installation version="1.0">
    <variables>
        <variable name="TargetPanel.dir.windows" value="$USER_HOME\MyTeamNinja"/>
        <variable name="TargetPanel.dir.mac" value="$USER_HOME/MyTeamNinja"/>
    </variables>
    <info>
        <appname>My App</appname>
        <appversion>1.0</appversion>
        <authors>
            <author name="MyTeamNinja" email="[email protected]"/>
        </authors>
        <url>http://myteam.ninja</url>
    </info>
      <guiprefs width="640" height="480" resizable="yes"/>
    <locale>
        <langpack iso3="eng"/>
    </locale>
    <panels>
        <panel classname="DefaultTargetPanel"/>
        <panel classname="InstallPanel"/>
        <panel classname="SimpleFinishPanel"/>
    </panels>
    <packs>
        <pack name="Base" required="yes">
            <description>The base files</description>
            <fileset dir="dist" targetdir="$INSTALL_PATH"/>
        </pack>
    </packs>
</installation>

Now as soon as I click the installer it starts the install but in c:\program files\My App\

Upvotes: 0

Views: 2887

Answers (1)

sunbabaphu
sunbabaphu

Reputation: 1493

what you need is a TargetPanel. it allows the user to select the destination dir. to install the files. the location selected in this panel sets the value of $INSTALL_PATH.

however, you may also override the default value of the $INSTALL_PATH.in order to override the default value of $INSTALL_PATH, you may do the following:

<variables>
  <variable name="TargetPanel.dir.windows" value="$USER_HOME/MyApp"/>
  <variable name="TargetPanel.dir.unix" value="$USER_HOME/MyApp"/>
</variables>

or,

<variables>
  <variable name="DEFAULT_INSTALL_PATH" value="$USER_HOME/MyApp"/>
</variables>  

and also, remember to include the TargetPanel before the InstallPanel in case you choose to allow the user to select the target loc. for the installation.

    <panels>
        <panel classname="TargetPanel"/>
        <panel classname="InstallPanel"/>
    </panels>

See HERE for more on this.


UPDATE:

  • place the entry for TargetPanel before the InstallPanel in the <panels> section.
  • remove the <resources> section:
    <resources> <res id="TargetPanel.dir.windows" src="$USER_HOME/MyApp"/> <res id="TargetPanel.dir.unix" src="$USER_HOME/MyApp"/> </resources> This is where the error is being generated. Instead use <variables> to specify default values for ${INSTALL_PATH} (see in my answer above).
  • also, to set a value for ${INSTALL_PATH} through <variables> you need to use name="DEFAULT_INSTALL_PATH" or TargetPanel.dir.windows/unix

UPDATE 2: The following piece of code installs in the correct location (as specified by you in the defaultInstallDir.txt).

<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<installation version="1.0">
    <!-- variables>
        <variable name="TargetPanel.dir.windows" value="$USER_HOME\MyTeamNinja"/>
        <variable name="TargetPanel.dir.mac" value="$USER_HOME/MyTeamNinja"/>
    </variables -->

    <!-- remove the above <varible> section and include the REQUIRED defaultInstallDir.txt to set the value for the DefaultTargetPanel -->
    <resources>
        <res id="TargetPanel.dir" src="defaultInstallDir.txt"/>
    </resources>

    <info>
        <appname>My App</appname>
        <appversion>1.0</appversion>
        <authors>
            <author name="MyTeamNinja" email="[email protected]"/>
        </authors>
        <url>http://myteam.ninja</url>
    </info>
      <guiprefs width="640" height="480" resizable="yes"/>
    <locale>
        <langpack iso3="eng"/>
    </locale>
    <panels>
        <panel classname="DefaultTargetPanel"/>
        <panel classname="InstallPanel"/>
        <panel classname="SimpleFinishPanel"/>
    </panels>
    <packs>
        <pack name="Base" required="yes">
            <description>The base files</description>
            <fileset dir="dist" targetdir="$INSTALL_PATH"/>
        </pack>
    </packs>
</installation>   

now, create a file named defaultInstallDir.txt and simply write the following within this file :

$USER_HOME/MyApp  

just make sure that you include this file correctly in the installer through the src=".." attribute of the <resources> section and you're good to go.
double clicking on the installer directly installs the files in $USER_HOME/MyApp (in my case: at C:\Users\Sunny\MyApp)

Upvotes: 1

Related Questions