How do I make the installer perform a string substitution as part of the installation?

Answered

Comments

1 comment

  • Avatar
    Jake

    You can perform string substitutions with the substitution action. This action allows you to specify pattern/value pairs that will be substituted in certain files. It takes a list of glob file patterns separated by ';' and a list of the pattern/value pairs.

           <substitute>
             <files>*/launcher/launchMyJavaApp.sh;*/bin/*.sh</files>
             <substitutionList>
               <substitution>
                 <pattern>@@INSTALLDIR@@</pattern>
                 <value>${installdir}</value>
               </substitution>
               <substitution>
                 <pattern>@@JAVADIR@@</pattern>
                 <value>${installdir}/jre</value>
               </substitution>
             </substitutionList>
           </substitute>
    

    Suppose the user sets /home/user/application as installdir and the original launchMyJavaApp.sh looked like:

    #!/bin/sh
    export MYAPPDIR=@@INSTALLDIR@@
    @@JAVADIR@@/bin/java com.some.class.Name
    

    Then the script will look like the following after installation:

    #!/bin/sh
    export MYAPPDIR=/home/user/application
    /home/user/application/jre/bin/java com.some.class.Name
    

    You can find more information about this action in Actions section of the product documentation included with InstallBuilder.

Please sign in to leave a comment.