Daily Archives: July 31, 2014

Access to Ant properties from IzPack XML

Inside the installation XML the access to Ant properties per

@{ant.property.name}

will only work, if you insert the whole XML content as CDATA into the build.xml

<IzPack output="${dist.dir}/IzPack-install.jar"
        installerType="standard"
        basedir="${dist.dir}"
        IzPackDir="${dist.dir}/">
        <config><![CDATA[
<installation version="1.0">
   <info>
      <appname>@{my.app.name.defined.in.build.xml}</appname>
      ...
   </info>
...
        ]]></config>
</IzPack>

If you use different files, the properties are unknown within the IzPack file. But there is a simple solution: Copy the install.xml into a temporary file and expand the properties during this step.

<target name="installer" depends="jar" description="compiles the IzPack installer">
	<copy overwrite="yes" verbose="yes" file="${dir.install}/izpack/install-definition.xml" tofile="${java.io.tmpdir}/install-definition.xml">
		<filterchain>
			<expandproperties />
		</filterchain>
	</copy>
	<IzPack input="${java.io.tmpdir}/install-definition.xml" output="${dir.dest}/${app.name}-install.jar" installerType="standard" basedir="${basedir}" />
</target>

So you can use ${app.name} inside the install.xml (don’t use @{app.name}). But you shouldn’t use Ant properties, which are redefined by IzPack itself or in a <variable> tag section. These properties are expanded before Ant calls IzPack and could contain the wrong values.

Special characters within IzPack XML

If you need some defined XML entities like é within the IzPack installation XML, you can’t use it there. The reason: they aren’t defined. But you can define a subset within your XML:

  <?xml version="1.0" encoding="iso-8859-1" ?>
  <!DOCTYPE installation [
  <!ENTITY % iso-lat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML"
                    "http://www.oasis-open.org/docbook/xmlcharent/0.3/iso-lat1.ent">
  %iso-lat1;
  ]>
  <installation version="1.0">
    <!-- start here -->
  </installation>

These additional lines include the usual entities. It is now possible to use:

  <authors>
    <author name="Andr&eacute; Rothe" email="andre.rothe@domain.local" />
  </authors>