Using Install4j With Ant


Integrating install4j with your Ant script (read about Ant at ant.apache.org) is easy. Just use the install4j task that is provided in $INSTALL4J_HOME/bin/ant.jar and set the projectfile parameter to the install4j project file that you want to build.

To make the install4j task available to Ant, you must first insert a taskdef element that tells Ant where to find the task definition. Here is an example of using the task in an Ant build file:

<taskdef name="install4j"
         classname="com.install4j.Install4JTask"
         classpath="C:\Program Files\install4j\bin\ant.jar"/>

<target name="media">
  <install4j projectfile="myapp.install4j"/>
</target>

On macOS, the ant.jar file is inside the application bundle, for the default application directory the full path is /Applications/install4j.app/Contents/Resources/app/bin/ant.jar

The taskdef definition must occur only once per Ant build file and can appear anywhere on the top level below the project element.

Note that it is not possible to copy the ant.jar archive to the lib folder of your ant distribution. You have to reference a full installation of install4j in the task definition.

Task parameters

The install4j task supports the following parameters:

AttributeDescriptionRequired
projectfileThe install4j project file that should be build.Yes
verbose Corresponds to the --verbose command line option. Either true or false. No, verbose and quiet cannot both be true
quiet Corresponds to the --quiet command line option. Either true or false.
license Corresponds to the --license command line option. If the license has not been configured yet, you can set the license key with this attribute. Yes
test Corresponds to the --test command line option. Either true or false. No, test and incremental cannot both be true
incremental Corresponds to the --incremental command line option. Either true or false.
debug Corresponds to the --debug command line option. Either true or false. No
preserve Corresponds to the --preserve command line option. Either true or false. No
faster Corresponds to the --faster command line option. Either true or false. No
disableSigning Corresponds to the --disable-signing command line option. Either true or false. No
winKeystorePassword Corresponds to the --win-keystore-password command line option. No
macKeystorePassword Corresponds to the --mac-keystore-password command line option. No
appleId Corresponds to the --apple-id command line option. No
appleIdPassword Corresponds to the --apple-id-password command line option. No
release Corresponds to the --release command line option. Enter a version number like "3.1.2". Version number components can be alphanumeric and should be separated by dots, dashes or underscores. No
destination Corresponds to the --destination command line option. Enter a directory where the generated media files should be placed. No
buildselected Corresponds to the --build-selected command line option. Either true or false. No
buildids Corresponds to the --build-ids command line option. Enter a list of media file ids. The IDs for media files can be shown in the install4j IDE by choosing Project->Show IDs from the main menu. No
mediatypes Corresponds to the --media-types command line option. Enter a list of media types. To see the list of supported media types, execute install4jc --list-media-types. No

Contained elements

Complete example

The "hello" sample project includes an Ant build script that shows how to setup the install4j task. To install the sample projects, invoke Project->Open Sample Project from the install4j IDE. When you do this for the first time, the sample projects are copied to the "Documents" folder in your home directory.

In the samples/hello directory, execute

ant media

to start the build. If you have not defined install4jHomeDir in build.xml, the build will fail with a corresponding error message.