Using an Ant Task to Build Installers from the Command Line

InstallAnywhere 2020

Ant is a powerful, Java based build tool developed by the Apache Foundation’s Jakarta Project. It can be used to control complex build tasks in Java and other development environments. Ant manages specific actions though tasks, which can be part of the core Ant distribution or available as extensions.

InstallAnywhere includes an Ant task to build installers from Ant. The InstallAnywhere Ant task (iaant.jar) is located in your InstallAnywhere application folder:

IA_HOME\resource\build\iaant.jar

Tip • To integrate the InstallAnywhere Ant task in an Ant project, set the classpath of the InstallAnywhere Ant task to the location of iaant.jar.

Note • The use of iaant.jar requires Java 1.4 or later.

Ant uses an XML file to specify the order of tasks for your build process. For more information on Ant, visit the Apache Foundation’s Ant Project Web site (http://ant.apache.org).

The following sections explain how to use the InstallAnywhere Ant task for your InstallAnywhere project.

Task Definition

Add a task definition to your Ant project for the InstallAnywhere Ant task.

<taskdef name="buildinstaller" classname="com.zerog.ia.integration.ant.InstallAnywhereAntTask">

    <classpath>

        <pathelement path="IA_HOME/resource/build/iaant.jar"/>

    </classpath>

</taskdef>

Task Settings

After defining the task, specify any parameter necessary for the build settings.

<buildinstaller IAProjectFile="Project_File_Path"

        IALocation="IA_HOME"

        i5OSLogin="hostname_or_ip/userName/password">

    <configuration name="Configuration_Name"

        webenabled="true/false"

        weboptimize="true/false"

        webpagelanguage="en/ja"

        cdenabled="true/false"

        cdoptimize="true/false"

        mergeenabled="true/false"

        mergeoptimize="true/false"

        mergereadonly="true/false">

        <locales>

            <localeSuffix>en</localeSuffix>

            <localeSuffix>de</localeSuffix>

            <localeSuffix>ja</localeSuffix>

            ...

            ...

        </locales>

        <target platform="windows"

            outputDir="outputDir"

            buildWithVM="true/false"

            buildWithNoVM="true/false"

            bundledVM="path_to_file" />

        <target platform="linux"

            outputDir="outputDir"

            buildWithVM="true/false"

            buildWithNoVM="true/false"

            bundledVM="path_to_file" />

        ...

        ...

    </configuration>

    ...

    ...

</buildinstaller>

Replace the IALocation value with the absolute path to your own InstallAnywhere application folder.

Specify the path and file name of the project to build in the IAProjectFile parameter.

All other properties are optional. The parameters closely match the properties in the BuildProperties.xml file.

Task Parameters

For a list of the supported Ant task parameters, see InstallAnywhere Ant Task Reference.

Sample Ant Tasks

Following is an example of an InstallAnywhere Ant task:

<taskdef name="buildinstaller" classname="com.zerog.ia.integration.ant.InstallAnywhereAntTask">

  <classpath>

    <pathelement path="c:\ant\lib\ext\iaant.jar"/>

  </classpath>

</taskdef>

...

<buildinstaller

  IALocation="IA_HOME"

  IAProjectFile="C:\Projects\myproject.iap_xml"

  BuildLinuxWithoutVM="true"

  BuildWindowsWithoutVM="true"

  BuildWebInstallers="true"

  OptimizeWebInstallers="true"

  InstallerStdErrRedirect="C:\console.txt"

  />

  <configuration name="MacBuildConfig">

    <locales>

        <localeSuffix>en</localeSuffix>

        <localeSuffix>de</localeSuffix>

        <localeSuffix>ja</localeSuffix>

    </locales>

    <target platform="macosx" buildWithNoVM="true"/>

  </configuration>

<buildinstaller/>

The following samples demonstrate how to use an InstallAnywhere Ant task to configure and build installers.

Using an External File to Specify Build Information

If you want to pass build properties for your Ant task in a single external file, you can use an external BuildProperties.xml file or an external buildproperties.properties file and the -p command-line argument. For example:

<buildinstaller

    IALocation="IA_HOME"

    IAProjectFile="C:\Projects\myproject.iap_xml"

    additionalparameter=value

>

    <arg value="-p"/>

    <arg value="path_to_BuildProperties.xml_or_buildproperties.properties_files"/>

</buildinstaller>

Note • For more information, see BuildProperties.xml File and buildproperties.properties File.

Setting Source Path Variables Using the Ant Task

You can use source paths to specify where payload files should be included at build time. You can use an environment variable to specify the source path’s value at build time.

The InstallAnywhere Ant task extends the Exec Ant task that is part of Ant’s core set of tasks. The Exec task allows environment variables to be passed to the command using <env> elements. Because the InstallAnywhere Ant task extends the Exec task, it also allows environment variables to be set using <env> elements.

Note • For information on the Exec Ant task, see http://ant.apache.org/manual/Tasks/exec.html.

For each source path that needs to be modified, an environment variable such as IA_PATH_SOURCE_PATH needs to be set, where IA_PATH_SOURCE_PATH is the name of the source path that is being referenced.

The following Ant target example uses the <env> element to set the source path IA_PATH_BILLBOARDS_PATH to the path X:\billboards\BillboardProblem:

<env key="IA_PATH_BILLBOARDS_PATH" value="X:\billboards\BillboardProblem" />

All references to the IA_PATH_BILLBOARDS_PATH source path in the project are substituted with this path at build time.

<target name="build-installer" description="Run Install Anywhere build only." >

    <buildinstaller

     IAlocation="${IA_HOME}"

     failonerror="true"

     IAProjectFile="${IA_PROJECT_FILE}"

    >

        <configuration name="Default Configuration">

            <target platform="Windows"

                outputDir="windows"

                buildWithVM="false"

                buildWithNoVM="true" />

        </configuration>

        <env key="IA_PATH_BILLBOARDS_PATH" value="X:\billboards\BillboardProblem" />

    </buildinstaller>

</target>

Specifying Build-Time Variables in a Properties File

In an Ant task, you can specify a property file that contains build-time variables.

<project default="test">

    <taskdef name="buildinstaller" classname="com.zerog.ia.integration.ant.InstallAnywhereAntTask">

        <classpath>

            <pathelement path="IA_HOME\\resource\\build\\iaant.jar" />

        </classpath>

    </taskdef>

    <target name="test">

        <buildinstaller IALocation="IA_HOME" IAProjectFile="ProjectFilePath"

            buildtimevarpropfile="PathToPropertiesFileContainingBuildTimeVariables">

            <configuration name="Default_Configuration">

                <target platform="Windows" outputDir="OutputDirectory" buildWithVM="false"
                    buildWithNoVM="true" />

            </configuration>

        </buildinstaller>

    </target>

</project>