Ant Client

We have an integration with Apache Ant 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
  2. Install Apache Maven
  3. Download the Apache Commons packages "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. 
  4. Check-out the ESME java client: _https://svn.apache.org/repos/asf/esme/trunk/esme-java-client_
  5. 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. 
  6. Create _lib _directory and copy "rest-api-0.1-SNAPSHOT.jar", "commons-codec-1.2.jar", "commons-httpclient-3.1.jar" into this directory. 
  7. Create src directory and copy the "EsmeAntTask.java" file to this directory
  8. Change the build.xml file to point to the appropriate directories
  9. Change the token in the "esme" target in the build.xml file to a correct token.
  10. Change the proxy in the "esme" target in the build.xml file to a correct proxy.
  11. call ant dist esme to test the application

Build.xml

{code:lang=xml}

<path id="project.class.path">
<pathelement

path="./dist/lib/EsmeViaAnt.jar:./lib/esme-rest-api-0.1.jar:./lib/commons-codec-1.4.jar:./lib/commons-logging-1.1.1.jar:./lib/commons-httpclient-3.1.jar"/>

<!-- Put everything in ${build} into the jar file -->
<jar jarfile="${dist}/lib/EsmeViaAnt.jar" basedir="${build}"/>

   </java>
h4. EsmeAntTask java class

import org.apache.esme.api.EsmeRestApi; import org.apache.esme.model.Message;

public class EsmeAntTask {

public static void main (String args) {

String apiUrl; String authToken; String localProxy; String message; EsmeRestApi esme;

apiUrl = args0 ; authToken = args1 ; localProxy = args2 ; message = args3 ;

try {

 esme = new EsmeRestApi(apiUrl);

 if ((localProxy != null) && !("".equals(localProxy)))
 {
    // Split proxyHost:port into two parts
            String[](.html)

proxy = localProxy.split(":"); esme.setProxy(proxy0 , Integer.parseInt(proxy[1])); }

 esme.login(authToken);

 Message esmeMsg = new Message();

 esmeMsg.setBody(message);

     String[](.html)

tags = new String[1]; tags0 = "Ant Task";

 esmeMsg.setTags(tags);

 esmeMsg.setSource("Ant");

 esme.sendMsg(esmeMsg);

} catch (Exception e) {} } }