Integrating with Ant

Tcat Server reached its End of Life in 2017. Contact your Customer Success Manager to determine options for managing, monitoring, or deploying your application.

Apache Ant may integrate with the Tcat Server console via HTTP. Ant has a built in HTTP client, including an HTTP <get> Ant task, but Ant does not include HTTP POST or PUT tasks. You may add tasks to your Ant build environment by downloading the following JARs containing additional Ant tasks.

Here is a list of the open source components and which JAR files are required from each:

Ant-Contrib 1.0b3

Sardine Task

HttpClient 4.0.3

HttpCore 4.1

Jakarta Commons Codec 1.4

Jakarta Commons Logging 1.0.4

Continuous Webapp Build and Deployment

If you need to automate uploading your webapps into the Tcat Server console repository and deploying them automatically, as part of your Ant build, here are the steps:

  1. Log into the console via your web browser.

  2. Navigate to the top-level Deployments tab.

  3. Create a new deployment by clicking the New Deployment button and filling out the form.

  4. Upload the first copy of your webapp into your new deployment.

  5. Save the deployment. You do not necessarily need to deploy it yet.

  6. Obtain your new deployment’s object ID by listing the deployments via Tcat’s REST API. One way to do this is using the curl command (you may already have it installed):

    $ curl --basic -u admin:youradminpassword http://localhost:8080/console/api/deployments

The output lists all your deployments, including their full URLs. On the end of the URL is the ID of the deployment.

Example: local$4f1b9bf8-613d-41d4-9423-09ccc33fa20e. Edit the following Ant build file’s property values (at the top), and set your Tcat Server console hostname and port number, deployment’s ID, username and password, and the dir and filename of your webapp’s WAR file:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="build" name="tcat-deployment-update">

  <!-- Properties required for calling the update-tcat-deployment target. -->
  <property name="" value="localhost"/>
  <property name="tcat.console.port" value="8080"/>
  <property name="tcat.console.user" value="admin"/>
  <property name="tcat.console.pass" value="admin"/>
  <property name="" value="local$4f1b9bf8-613d-41d4-9423-09ccc33fa20e"/>
  <!-- This is the path of the directory where your WAR file resides. -->
  <property name="war.dist.dir" value="${basedir}/dist"/>
  <!-- This is just the filename of your WAR file, not containing directories. -->
  <property name="war.filename" value="mywebapp.war"/>
  <!-- You might want to use a version control revision number for war.rev.number. -->
  <property name="war.rev.number" value="2"/>

  <!-- Include the ant-contrib tasks. -->
  <taskdef resource="net/sf/antcontrib/antlib.xml">
      <fileset dir="${basedir}/lib">
        <include name="ant-contrib-1.0b3.jar"/>
      <fileset dir="${basedir}/lib">
        <include name="commons-httpclient-3.0.1.jar"/>
      <fileset dir="${basedir}/lib">
        <include name="commons-logging-1.0.4.jar"/>
      <fileset dir="${basedir}/lib">
        <include name="commons-codec-1.4.jar"/>

  <!-- Include the sardine task (to use the HTTP PUT method). -->
  <typedef resource="com/googlecode/sardine/ant/sardinetask.xml">
      <fileset dir="${basedir}/lib">
        <include name="sardine.jar"/>
      <fileset dir="${basedir}/lib">
        <include name="httpclient-4.0.3.jar"/>
      <fileset dir="${basedir}/lib">
        <include name="httpcore-4.1.jar"/>
      <fileset dir="${basedir}/lib">
        <include name="httpmime-4.0.3.jar"/>
      <fileset dir="${basedir}/lib">
        <include name="commons-logging-1.0.4.jar"/>
      <fileset dir="${basedir}/lib">
        <include name="commons-codec-1.4.jar"/>

  <target name="build">
    <!-- Build your webapp, then send it to the Tcat Server console repository. -->
    <antcall target="tcat-deployment-update"/>

  <target name="tcat-deployment-update"
          description="Uploads the WAR to the Tcat repository + redeploys">
    <!-- Upload (POST) the war file into the Tcat Server console repository. -->
    <echo>POST http://${}:${tcat.console.port}/console/api/registry/Applications/${war.filename} rev ${war.rev.number}</echo>
    <postMethod url="http://${}:${tcat.console.port}/console/api/registry/Applications/${war.filename}"
      <header name="Title" value="${war.filename}"/>
      <header name="Slug" value="${war.filename}"/>
      <header name="X-Artifact-Version" value="${war.rev.number}"/>
      <file path="${war.dist.dir}/${war.filename}"/>
        <clientParams authenticationPreemptive="true"/>
          <credentials host="${}"

    <!-- Retrieve the webapp's deployment metadata from Tcat's console repository. -->
    <property name="tcat.deployment.file" value="${war.dist.dir}/.deployment.txt"/>
    <delete file="${tcat.deployment.file}" failonerror="false"/>
    <get src="http://${}:${tcat.console.port}/console/api/deployments/${}"

    <!-- Update the deployment metadata with the new revision number. -->
    <replaceregexp file="${tcat.deployment.file}"
                   flags="g" byline="true"/>

    <!-- PUT the deployment metadata back to the console, and redeploy the webapp. -->
    <echo>Updating deployment metadata and redeploying ${war.filename}.</echo>
    <sardine username="${tcat.console.user}"
      <put url="http://${}:${tcat.console.port}/console/api/deployments/${}"
        <fileset dir="${war.dist.dir}">
          <include name=".deployment.txt"/>


Run Ant, and this build file uploads the WAR file as a new revision of the webapp you uploaded via your web browser. Update the deployment metadata so that the deployment uses the new revision, and save the deployment metadata into the console. This causes the console to trigger a redeployment.

After using the Ant script to update your applications, you can schedule a script to listen for these updates and automatically redeploy their packages. For an example, see Automatically Redeploying After an Artifact Update.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub