+

Search Tips   |   Advanced Search

Build a project WAR file with Ant

We can build the project WAR file using Ant tasks.

Make sure Apache Ant is installed. The minimum supported version of Ant is listed in System requirements for using MPF.

Apache Ant 1.8.4 is included in MobileFirst Server. In the MF_HOME/shortcuts/ directory, the following scripts are provided:

These scripts do not require specific environment variables. If the JAVA_HOME environment variable is set, the scripts accept it.

Since IBM Worklight Foundation v6.2.0, the worklight-ant-builder.jar file is included in the MPF Command Line Interface, whereas in earlier versions, it was included in MobileFirst Server. By default, worklight-ant-builder.jar is installed in the following location: <CLI Install Path>/public/worklight-ant-builder.jar. For example, on OSX, the default CLI Install Path is /Applications/IBM/Worklight-CLI. If we use the default installation path, the Ant task is installed here: /Applications/IBM/Worklight-CLI/public/worklight-ant-builder.jar.

The Ant task for building a MobileFirst project WAR file has the following structure:

<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="all">
  <taskdef resource="com/worklight/ant/defaults.properties">
    <classpath>
      <pathelement location="cli_install_dir/public/worklight-ant-builder.jar"/>
    </classpath>
  </taskdef>
  <target name="all">
    <war-builder projectfolder="."
                 destinationfolder="bin/war"
                 warfile="bin/project.war"
                 classesFolder="classes-folder"/>
  </target>
</project>
The <war-builder> element has the following attributes:


Parent topic: Deploy MobileFirst applications to test and production environments