Let the ants feed the bird: ant-twitter, a Twitter task for Ant


I have learned the last 5 day for business studies and was so bored that I really got happy when I saw the article about a Twitter-Maven-Plugin on entwickler.com yesterday morning.
We still use Ant as building system in our development team so I searched for an Ant task which enables Twitter support. As I did not found any plugin I started to write my own simple task called ant-twitter.

Features

  • Support for URL shortening service bit.ly via bitlyj
  • Support for messages more than 140 characters – the message will be splitted into two or more messages. A small source snippet is taken  from jtwitter – thanks a lot guys!
  • Open source – Apache license
  • It is simple :)

Installation

I assume you have already installed Ant-1.70 (1.6x should work although) and configured your Ant working environment. I refer to $ANT_LIB$ which is a directory where your Ant installation can found further JARs (should be appended to your classpath).

  • Download needed packages and extract them to $ANT_LIB$:
  • Create a file twitter4j.properties in your classpath ($ANT_LIB$) and paste the following code into it:
    twitter4j.http.useSSL=true
    twitter4j.debug=false
    

Usage

After you have installed the needed dependencies and upset your configuration you have to edit your build.xml. Put the following taskdef in top of your build file:

<project name="TwitterTestTask" default="main" basedir=".">
  <taskdef name="twitter" classname="de.ecw.ant.twitter.AntTwitterTask"/>

You are now able to use the twitter task in form of

    <twitter message="Hello World from Ant!" username="twitter-username" password="twitter-password" bitlyUsername="bitly-username" bitlyApiKey="bitly-key" enableBitly="false" />

ant-twitter has the following options:

  • message (required, String): Your Twitter tweet
  • username (required, String): Your Twitter screenname
  • password (required, String): Your Twitter password
  • bitlyUsername (optional, required if enableBitly=true, String): Your bit.ly username
  • bitlyApiKey (optional, required if enableBitly=true, String): Your bit.ly API key
  • enableBitly (optional, true|false): Enable bit.ly support

, , , , , , ,

  1. #1 von Christian Pesch am 20. November 2009

    Nice idea, you have tagged your post with ‘maven’: Do you plan to release a Maven plugin?

  2. #2 von Schakko am 20. November 2009

    No, I did not plan to release this task as a Maven plug-in.
    As far as I know it is possible to use Ant tasks in Maven, so you could use already ant-twitter.

(wird nicht veröffentlicht)

*
To prove you're a person (not a spam script), type the answer to the math equation shown in the picture. Click on the picture to hear an audio file of the equation.
Click to hear an audio file of the anti-spam equation


  1. Bisher keine Trackbacks.