izpackizpanel

izpack how to replace backslash "\" with slash "/" or with "\\" in windows directory location with space


I am using izpack installer to install the application which I developed in Windows. My application root-folder will have space in it. There is a property with folder location in configuration .properties file.

PluginFolder=${plugin.dir}  

For example my sample windows-directory location is "C:\My Application Folder\Plugins Folder"

Which required to replace with actual folder-path after installation as follows, because java can not read property in file with only "\" in folder-path.

PluginFolder=C:\\My Application Folder\\Plugins Folder

or 

PluginFolder=C:/My Application Folder/Plugins Folder

Any one of the above will work fine with my application.

In izpack installer Folder location reads using

<panel ...>
...
   <field type="dir" align="left" variable="plugin.dir">
      <spec txt="Plugin Directory :" size="25" set="${plugin.default.dir}" />
   </field>
....
</panel>

And properties in configuration file is set using

<parsable targetfile="$INSTALL_PATH/config/myapp.properties" type="javaprop">
   <os family="windows" />
</parsable>

But use of type="javaprop" in izpack installer is appending "\" with SPACE present in folder path. That I do not required as my application is not able to read it.

PluginFolder=C:\\My\ Application\ Folder\\Plugins\ Folder

Use of type="java" works fine if there is no space in folder-path and replace all the "\" with "\". But with space in folder-path, which is very likely in Windows and also required for my application it is not working.

Actually I do not want "SPACE" in folder-path to be replaced by "\SPACE".

Guys please help me to resolve this issue in izpack installer.


Solution

  • You can work around this behavior e.g. by using dynamic variables with filtering:

    <dynamicvariables>
      <variable name="plugin.dir.parsed" value="${plugin.dir}">
        <filters>
          <regex regexp="[/\\]+" replace="/" global="true" />
        </filters>
      </variable>
    </dynamicvariables>