Search code examples
antbuild.xmllaunch4jvariable-expansion

How use property expansion in a Launch4j config file


I use Launch4j and will use a property ${dist} in its configuration.

It works when the task and it argument directly are in the build.xml file:

<project ...>
    <property name="dist" location="/temp/dist" />
    <launch4j>
        <config headerType="gui" outfile="${dist}/myprogram.exe"
            dontWrapJar="false" jarPath="${dist}/myprogram.jar">
            ...
        </config>
    </launch4j>

</project>

Launch4j can however use its own xml-configuration file, with <launch4jConfig> as root element:

in ant.xml:

<launch4j configFile="my_launch4j_config.xml" />

in my_launch4j_config.xml:

<launch4jConfig>
    <headerType>gui</headerType>
    <outfile>${dist}/myprogram.exe</outfile>
    <dontWrapJar>false</dontWrapJar>
        <jar>${dist}/myprogram.jar</jar>
        ...
</launch4jConfig>

In this case, ${dist} is not expanded, nor %dist% or everything I tried... Does a solution exist to use properties in an launch4j config file?


Solution

  • The code of launch4j did not accept such replacements of parameters, but I could change this behaviour (modifications to net.sf.launch4j.config.ConfigPersister). I check it in the Sourceforge project when I have enough time for it.