Terracotta setup using Ant tutorial

I just started using Terracotta for the first time.  This is how I put it in my project and configured Ant tasks to start and stop the server. The client is using Windows, so the Ant tasks work in Windows.

  1. Create tc-config.xml in the root of the project.
    <?xml version="1.0" encoding="UTF-8"?>
    <con:tc-config xmlns:con="http://www.terracotta.org/config">
      <servers>
        <server host="%i" name="localhost">
          <dso-port>9510</dso-port>
          <jmx-port>9520</jmx-port>
          <data>bin/terracotta/server-data</data>
          <logs>bin/terracotta/server-logs</logs>
          <statistics>bin/terracotta/cluster-statistics</statistics>
        </server>
        <update-check>
          <enabled>true</enabled>
        </update-check>
      </servers>
      <clients>
        <logs>bin/terracotta/client-logs</logs>
        <statistics>bin/terracotta/client-statistics/%D</statistics>
        <modules>
          <module name="tim-hibernate-3.2.5" version="1.2.2"/>
          <module name="tim-ehcache-1.3" version="1.2.2"/>
          <module name="tim-cglib-2.1.3" version="1.2.2"/>
          <module name="tim-ehcache-commons" version="1.2.2"/>
        </modules>
      </clients>
    </con:tc-config>
  2. Put Terracotta into your library directory.  You’ll need bin, docs, lib and schema directories and the license files.
    1. You don’t need the licenses for the software to work, but it’s always a good idea to include them, especially if your app is not open source 😛
  3. Create the Ant targets.
    <target name="start.terracotta.windows">
      <exec executable="cmd">
        <arg value="/c"/>
        <arg value="lib\terracotta-2.7.2\bin\start-tc-server.bat"/>
      </exec>
    </target>
    
    <target name="stop.terracotta.windows">
      <exec executable="cmd">
        <arg value="/c"/>
        <arg value="lib\terracotta-2.7.2\bin\stop-tc-server.bat"/>
      </exec>
    </target>
    1. Notice the backslashes there.  Normally, Ant will convert forward slashes to backslashes in Windows.  Since this is a command line argument, though, it doesn’t.  If you’re running on both *nix and Windows, you’ll have to have two versions of the paths, one with forward and one with back slashes.
  4. That’s it. Run the start task to start and the stop task to stop.