Title: Ant Client
We have an integration with [Apache Ant](http://ant.apache.org/)
which is “a Java-based build tool”. It is now possible to send
messages to Apache ESME that describe the progress of your build steps.
This is especially useful when Apache ESME is being in development projects
where individual developers can be made aware of the status of
various-build related actions. For example, a development team could be
informed that a build is broken or if it is successful.
#### Setup
1. Install Apache Ant
1. Install Apache Maven
1. Download the Apache Commons packages ["Codec"](http://commons.apache.org/codec/)
and [Logger|http://commons.apache.org/logging/download_logging.cgi]
. We also need [Apache "Httpclient|http://hc.apache.org/] .
Please note that we are currently using the legacy 3.1 version of the
HTTP Client.
1. Check-out the ESME java client: \_[https://svn.apache.org/repos/asf/esme/trunk/esme-java-client\_](https://svn.apache.org/repos/asf/esme/trunk/esme-java-client_)
1. Perform a maven build in this directory with the following command "_mvn
compile package \-Dmaven.test.skip=true_" . This will create a jar file
"esme-rest-api-0.1.jar" in the target directory.
1. Create \_lib _directory and copy "rest-api-0.1-SNAPSHOT.jar",
"commons-codec-1.2.jar", "commons-httpclient-3.1.jar" into this
directory.
1. Create _src_ directory and copy the "EsmeAntTask.java" file to this
directory
1. Change the build.xml file to point to the appropriate directories
1. Change the token in the "esme" target in the build.xml file to a correct
token.
1. Change the proxy in the "esme" target in the build.xml file to a correct
proxy.
1. call _ant dist esme_ to test the application
#### Build.xml
{code:lang=xml}
h4. EsmeAntTask java class
import org.apache.esme.api.EsmeRestApi;
import org.apache.esme.model.Message;
public class EsmeAntTask
{
public static void main (String[](.html)
args) {
String apiUrl;
String authToken;
String localProxy;
String message;
EsmeRestApi esme;
apiUrl = args[0](0.html)
;
authToken = args[1](1.html)
;
localProxy = args[2](2.html)
;
message = args[3](3.html)
;
try {
esme = new EsmeRestApi(apiUrl);
if ((localProxy != null) && !("".equals(localProxy)))
{
// Split proxyHost:port into two parts
String[](.html)
proxy = localProxy.split(":");
esme.setProxy(proxy[0](0.html)
, Integer.parseInt(proxy[1]));
}
esme.login(authToken);
Message esmeMsg = new Message();
esmeMsg.setBody(message);
String[](.html)
tags = new String[1];
tags[0](0.html)
= "Ant Task";
esmeMsg.setTags(tags);
esmeMsg.setSource("Ant");
esme.sendMsg(esmeMsg);
}
catch (Exception e) {}
}
}