IBM Worklight v5.0.5 > Develop IBM Worklight applications > Transport Worklight applications to test and production environments

Build and deploy Ant tasks

IBM Worklight provides a set of Ant tasks for building and deploying adapters and apps to a WL server. A typical use of these Ant tasks is to integrate them with a central build service that is invoked manually or periodically on a central build server.

The Ant tasks are available with the IBM Worklight Enterprise Edition and the IBM Worklight Consumer Edition. They are not available with the IBM Worklight Developer Edition.


Build an application

The Ant task for building an application...

<?xml version="1.0" encoding="UTF-8"?>

<project base="." default="target-name">
    <target name="target-name">

        <taskdef resource="com/worklight/ant/defaults.properties">
            <classpath>
                <pathelement location="path_to_worklight-ant-platform.version.jar" />
            </classpath>
        </taskdef>

        <app-builder applicationFolder="adapter-source-files-folder"
                     environments="list-of-environments"
                     nativeProjectPrefix="project-name"
                     outputFolder="output-folder"/>

    </target>
</project>

The <app-builder> element has the following attributes:

applicationFolder Root folder for the application, which contains application-descriptor.xml and other source files for the application.
environments Comma-separated list of environments to build. This attribute is optional. The default action is to build all environments.
nativeProjectPrefix Mandatory when you build iOS applications
ouptputFolder Folder to which the resulting .wlapp file is written.

By default, running the Ant task to build an application does not handle the Dojo Toolkit, because Ant is not run with build-dojo.xml.

To configure the task to do so, set...

If you use this setting, the Dojo Toolkit files are deployed with your application.


Deploy an application

The Ant task for deploying an application...

<?xml version="1.0" encoding="UTF-8"?>
<project base="." default="target-name">
    <target name="target-name">
        <taskdef resource="com/worklight/ant/defaults.properties">
            <classpath>
                <pathelement location="path_to_worklight-ant-platform.version.jar" />
            </classpath>
        </taskdef>
        <app-deployer worklightServerHost="http://server-address:port" deployable="app.wlapp" />
    </target>
</project>

The <app-deployer> element has the following attributes:

worklightServerHost Full URL of the Worklight server.
deployable .wlapp file to deploy.

If deploying more than one .wlapp file, add an <app-deployer> element for each file.


Build an adapter

The Ant task for building an adapter...

<?xml version="1.0" encoding="UTF-8"?>
<project base="." default="target-name">
    <target name="target-name">
        <taskdef resource="com/worklight/ant/defaults.properties">
            <classpath>
                <pathelement location="path_to_worklight-ant-platform.version.jar" />
            </classpath>
        </taskdef>
        <adapter-builder folder="adapter-source-files-folder" destinationfolder="destination-folder" />
    </target>
</project>

The <adapter-builder> element...

folder Folder that contains the source files of the adapter (its .xml and .js files).
destinationfolder Folder to which the resulting .adapter file is written.

If build more than one adapter file, add an <adapter-builder> element for each adapter.


Deploy an adapter

The Ant task for deploying an adapter...

<?xml version="1.0" encoding="UTF-8"?>
<project base="." default="target-name">
    <target name="target-name">
        <taskdef resource="com/worklight/ant/defaults.properties">
            <classpath>
                <pathelement location="path_to_worklight-ant-platform.version>.jar" />
            </classpath>
        </taskdef>
        <adapter-deployer worklightserverhost="http://server-address:port" deployable="myAdapter.adapter" />
    </target>
</project>

The <adapter-deployer> element...

worklightserverhost Full URL of the Worklight server.
deployable .adapter file to deploy.

If deploy more than one .adapter file, add an <adapter-deployer> element for each file.


Deploy a project

The Ant task for deploying a project (building the server customization archive file)...

<?xml version="1.0" encoding="UTF-8"?>

<project name="myProject" default="all">

    <target name="taskdefs">
        <taskdef resource="com/worklight/ant/defaults.properties">
        <classpath>
            <pathelement location="home_directory/git/worklight/worklight-build-tools/target/classes" />
            <pathelement location="home_directory/git/worklightworklight-build-tools/target/worklight-build-tools-executable.jar" />
        </classpath>
    </taskdef>
    </target>

    <target name="all" depends="taskdefs">

        <war-builder projectfolder="." 
                     destinationfolder="bin/war" 
                     warfile="bin/cust.war"
                     classesFolder="classes-folder"/>
    </target>

</project>

The <war-builder> element has the following attributes:

projectfolder Path to your project.
destinationfolder Folder for holding temporary files.
warfile Destination and file name of the generated .war file
classesFolder Folder with compiled Java classes to add to the .war file. .jar files in the projectfolder\server\lib directory are added automatically


Parent Transport Worklight applications to test and production environments





+

Search Tips   |   Advanced Search