Deploying applications and adapters

You can use Ant tasks to deploy MobileFirst applications and adapters.

The following sections show examples of Ant XML files that use the wladm Ant task to deploy applications and adapters. You can run these Ant files locally on the MobileFirst Server host computer or remotely on a different computer. To run them remotely on a different computer, you must first copy the file product_install_dir/WorklightServer/worklight-ant-deployer.jar to that computer.

Deploying an application

Note: Before you use this Ant task, as a prerequisite step, you must deploy the corresponding MobileFirst project of the application. For more information, see Deploying the project WAR file.

A typical Ant script for deploying an application has the following structure:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="target-name">
  <taskdef resource="com/worklight/ant/deployers/antlib.xml">
    <classpath>
      <pathelement location="product_install_dir/WorklightServer/worklight-ant-deployer.jar"/>
    </classpath>
  </taskdef>
  <target name="target-name">
    <wladm url="https://server-address:secure-port/worklightadmin" user="username" password="password">
      <deploy-app runtime="project-name" file="myApp.wlapp"/>
    </wladm>
  </target>
</project>
The <wladm> element has the following attributes:
Table 1. Attributes of the <wladm> element
Attribute Mandatory/Optional Description
url Mandatory The full URL of your MobileFirst Server web application for administration services
user and password Mandatory The credentials of a user in a worklightadmin or worklightdeployer role
The <deploy-app> element has the following attributes:
Table 2. Attributes of the <deploy-app> element
Attribute Mandatory/Optional Description
runtime Mandatory The name of the MobileFirst runtime / project.
file Mandatory Contains the .wlapp file to deploy.

For more information about <wladm>, see Administering MobileFirst applications through Ant.

If you must deploy more than one .wlapp file, either add a <deploy-app> element for each file in a single <wladm> element, or add a <wladm> element for each file.

Deploying an adapter

Note: Before you use this Ant task, as a prerequisite step, you must deploy the corresponding MobileFirst project of the adapter. For more information, see Deploying the project WAR file.

A typical Ant script for deploying an adapter has the following structure:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="target-name">
  <taskdef resource="com/worklight/ant/deployers/antlib.xml">
    <classpath>
      <pathelement location="product_install_dir/WorklightServer/worklight-ant-deployer.jar"/>
    </classpath>
  </taskdef>
  <target name="target-name">
    <wladm url="https://server-address:secure-port/worklightadmin" user="username" password="password">
      <deploy-adapter runtime="project-name" file="myAdapter.adapter"/>
    </wladm>
  </target>
</project>
The <wladm> element has the following attributes:
Table 3. Attributes of the <wladm> element
Attribute Mandatory/Optional Description
url Mandatory The full URL of your MobileFirst Server web application for administration services
user and password Mandatory The credentials of a user in a worklightadmin or worklightdeployer role
The <deploy-adapter> element has the following attributes:
Table 4. Attributes of the <deploy-adapter> element
Attribute Mandatory/Optional Description
runtime Mandatory The name of the MobileFirst runtime / project.
file Mandatory Contains the .adapter file to deploy.

For more information about <wladm>, see Administering MobileFirst applications through Ant.

If you must deploy more than one .adapter file, either add a <deploy-adapter> element for each file in a single <wladm> element, or add a <wladm> element for each file.