Ant task for uploading or deleting an application

You can use the upload and delete tools as an Ant task and use the Ant task in your own Ant script.

Apache Ant is required to run these tasks. The minimum supported version of Apache Ant is listed in System requirements.

For convenience, Apache Ant 1.8.4 is included in IBM MobileFirst™ Platform Server. In the product_install_dir/shortcuts/ directory, the following scripts are provided:
  • ant for UNIX / Linux
  • ant.bat for Windows
These scripts are ready to run, which means that they do not require specific environment variables. If the environment variable JAVA_HOME is set, the scripts accept it.

When you use the upload tool as an Ant task, the classname value of the upload Ant task is com.ibm.appcenter.ant.UploadApps. The classname value of the delete Ant task is com.ibm.appcenter.ant.DeleteApps.

Parameters of Ant task Description
serverPath To connect to the Application Center. The default value is http://localhost:9080.
context The context of the Application Center. The default value is /applicationcenter.
loginUser The user name with permissions to upload an application.
loginPass The password of the user with permissions to upload an application.
forceOverwrite If set to true, the Ant task attempts to overwrite applications in the Application Center when it uploads an application that is already present. This parameter is available only in the upload Ant task.
file The .apk or .ipa file to be uploaded to the Application Center or to be deleted from the Application Center. This parameter has no default value.
fileset To upload or delete multiple files.
application The package name of the application; this parameter is available only in the delete Ant task.
os The operating system of the application. (For example, Android, iOS, or BlackBerry.) This parameter is available only in the delete Ant task.
version The internal version of the application; this parameter is available only in the delete Ant task. Do not use the commercial version here, because the commercial version is unsuitable to identify the version exactly.

Example

You can find an extended example in the ApplicationCenter/tools/build.xml directory.

The following example shows how to use the Ant task in your own Ant script.

<?xml version="1.0" encoding="UTF-8"?>
<project name="PureMeapAntDeployTask" basedir="." default="upload.AllApps">

  <property name="install.dir" value="../../" />
  <property name="workspace.root" value="../../" />

<!-- Server Properties -->
  <property name="server.path" value="http://localhost:9080/" />
  <property name="context.path" value="applicationcenter" /> 
  <property name="upload.file" value="" />
  <property name="force" value="true" />

  <!--  Authentication Properties -->
  <property name="login.user" value="appcenteradmin" />
  <property name="login.pass" value="admin" />
  <path id="classpath.run">
    <fileset dir="${install.dir}/ApplicationCenter/tools/">
      <include name="applicationcenterdeploytool.jar" />
      <include name="json4j.jar"/>
    </fileset>
  </path>
  <target name="upload.init">
    <taskdef name="uploadapps" classname="com.ibm.appcenter.ant.UploadApps"> 
      <classpath refid="classpath.run" />
    </taskdef>
  </target>
  <target name="upload.App" description="Uploads a single application" depends="upload.init">
    <uploadapps serverPath="${server.path}"
      context="${context.path}"
      loginUser="${login.user}"
      loginPass="${login.pass}"
      forceOverwrite="${force}"
      file="${upload.file}" />
    </target>
    <target name="upload.AllApps" description="Uploads all found APK and IPA files" depends="upload.init">
    <uploadapps serverPath="${server.path}"
      loginUser="${login.user}"
      loginPass="${login.pass}"
      forceOverwrite="${force}"
       context="${context.path}" >
      <fileset dir="${workspace.root}">
        <include name="**/*.ipa" />
      </fileset>
    </uploadapps>
  </target>
</project>

This sample Ant script is in the tools directory. You can use it to upload a single application to the Application Center.

ant upload.App -Dupload.file=sample.ipa

You can also use it to upload all applications that are found in a directory hierarchy.

ant upload.AllApps -Dworkspace.root=myDirectory

Properties of the sample Ant script

Property Comment
install.dir Defaults to ../../
server.path The default value is http://localhost:9080.
context.path The default value is applicationcenter.
upload.file This property has no default value. It must include the exact file path.
workspace.root Defaults to ../../
login.user The default value is appcenteradmin.
login.pass The default value is admin.
force The default value is true.

To specify these parameters by command line when you call Ant, add -D before the property name. For example:

-Dserver.path=http://localhost:8888/