Use Ant tasks to build applications and adapters
The worklight-ant-builder.jar file is included in the MPF Command Line Interface. In earlier versions, it was included in MobileFirst Server. By default, worklight-ant-builder.jar is installed in the following location:
cli_install_dir/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.
Building a hybrid application
The Ant task for building a hybrid application has the following structure:
<?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="target-name"> <taskdef resource="com/worklight/ant/defaults.properties"> <classpath> <pathelement location="cli_install_dir/public/worklight-ant-builder.jar"/> </classpath> </taskdef> <target name="target-name"> <app-builder worklightserverhost="http://server-address:port" applicationFolder="application-source-files-folder" environments="list-of-environments" nativeProjectPrefix="project-name" outputFolder="output-folder"/> </target> </project>The <app-builder> element has the following attributes:
- The worklightserverhost attribute is mandatory and specifies the full URL of the MobileFirst Server.
- The applicationFolder attribute specifies the root folder for the application, which contains application-descriptor.xml and other source files for the application.
- The environments attribute is a comma-separated list of environments to build. This attribute is optional. The default action is to build all environments.
- The nativeProjectPrefix attribute is mandatory when you build iOS applications
- The ouptputFolder attribute specifies the 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. We must explicitly configure the task to do so, using the following app-builder setting in the Ant build file:
skinBuildExtensions=build-dojo.xml
If we use this setting, the Dojo Toolkit files are deployed with your application.
Build a native API application
The Ant task for building a native API application has the following structure:
<?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="target-name"> <taskdef resource="com/worklight/ant/defaults.properties"> <classpath> <pathelement location="cli_install_dir/public/worklight-ant-builder.jar"/> </classpath> </taskdef> <target name="target-name"> <native-app-builder worklightserverhost="http://server-address:port" sourcefolder="application-source-files-folder" outputFolder="output-folder"/> </target> </project>The <native-app-builder> element has the following attributes:
- The worklightserverhost attribute is mandatory and specifies the full URL of the MobileFirst Server.
- The sourceFolder attribute specifies the root folder for the application, which contains the application-descriptor.xml file and other source files for the application.
- The ouptputFolder attribute specifies the folder to which the resulting .wlapp file is written.
Build an adapter
The Ant task for building an adapter has the following structure:
<?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="target-name"> <taskdef resource="com/worklight/ant/defaults.properties"> <classpath> <pathelement location="cli_install_dir/public/worklight-ant-builder.jar"/> </classpath> </taskdef> <target name="target-name"> <adapter-builder folder="adapter-source-files-folder" destinationfolder="destination-folder"/> </target> </project>The <adapter-builder> element has the following attributes:
- The folder attribute specifies the folder containing the source files of the adapter (its .xml and .js files).
- The destinationfolder attribute specifies the folder to which the resulting .adapter file is written.
If we build more than one adapter file, add an <adapter-builder> element for each adapter.
Parent topic: Ant tasks for building and deploying applications and adapters