Building a project WAR file with Ant
You can build the project WAR file by using Ant tasks.
Before you can run Ant tasks, make sure that Apache Ant is installed. The minimum supported version of Ant is listed in System requirements.
Apache Ant 1.8.4 is
included in MobileFirst Server.
In the product_install_dir/shortcuts/ directory,
the following scripts are provided:
- For UNIX / Linux: ant
- For Windows: ant.bat
Note: Since IBM® Worklight Foundation V6.2.0,
the worklight-ant-builder.jar file is included
in the IBM MobileFirst™ Platform 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 you 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:- The projectfolder attribute specifies the path to your project.
- The destinationfolder attribute specifies a folder for holding temporary files.
- The warfile attribute specifies the destination and file name of the generated .war file
- The classesFolder attribute specifies a folder with compiled Java™ classes to add to the .war file. .jar files in the projectfolder\server\lib directory are added automatically