Tweet your builds with Maven Twitter Plugin

Introduction

Maven Twitter Plugin lets you send Twitter status updates from Maven, without writing any Java code. It increases communication between Project owners and Project users by automatically tweeting build and release status via Twitter.

Configuration

1. Add Plugin repository to your <build> <plugins> section in pom.xml

You need to add this to your list of existing plugin repositories.

<pluginRepository>
 <id>vineetmanohar-release-repo</id>
 <name>Vineet Manohar Release Repo</name>
 <url>http://repo.vineetmanohar.com/releases</url>
</pluginRepository>

2. Add your twitter username, password to your ~/.m2/settings.xml file

For security reasons, it is recommended that you put your twitter username and password in your local settings file.

<settings>
 <profiles>
  <profile>
   <id>default</id>
   <activation>
    <activeByDefault>true</activeByDefault>
   </activation>
   <properties>
    <twitterUsername>your twitter username</twitterUsername>
    <twitterPassword>your twitter password</twitterPassword>
   </properties>
  </profile>
 </profiles>
</settings>

Usage

Add the Twitter plugin to your <build> <plugins> section in pom.xml

Define the plugin as shown in example below.

<build>
 ...
 <plugins>
  <plugin>
   <groupId>com.vineetmanohar</groupId>
   <artifactId>maven-twitter-plugin</artifactId>
   <version>0.1</version>
   ...
  </plugin>
</plugins>

Now add one <execution> block to the above, for every Tweet you want to send per build. The <twitterStatus> config element defines your Twitter message and will be executed in the phase specified by the <phase> subelement.

<execution>
 <phase>...</phase>
 <configuration>
   <twitterStatus>...</twitterStatus>
 </configuration>
</execution>

You can define as many blocks as you want.

Example

This example send 2 tweets: one in the “test” phase and the other in the “deploy” phase.

<plugin>
 <groupId>com.vineetmanohar</groupId>
  <artifactId>maven-twitter-plugin</artifactId>
  <version>0.1</version>
  <executions>
   <!-- phase: test -->
   <execution>
    <id>test-passed</id>
    <configuration>
     <!-- anything you want, upto 140 chars -->
     <twitterStatus>My first tweet from using #maven twitter plugin</twitterStatus>
    </configuration>
    <phase>test</phase>
    <goals>
     <goal>tweet</goal>
    </goals>
   </execution>

   <!-- phase: deploy -->
   <execution>
    <configuration>
     <!-- Tell your users that the project is deployed -->
     <twitterStatus>Version ${project.versionId} of XYZ deployed</twitterStatus>
    </configuration>
    <id>deploy</id>
    <phase>deploy</phase>
    <goals>
     <goal>tweet</goal>
    </goals>
   </execution>
  </executions>
</plugin>

FAQ

What can I put under the <twitterStatus> element

  • static text
  • You can be creative and put variables related to your project. ${project} maps to the Maven Project Model. Examples are ${project.groupId}, ${project.artifactId}, etc
  • You can put hash tags by simply putting # before a word
  • You can put @usernames directing the message to a specific twitter account
  • You resolved twitter message, after resolving any ${vars}, should be maximum 140 chars

What happens if I send multiple message with the same text

  • Twitter seems to ignore status updates if there is not status change from your.

What happens if my <twitterStatus> is more than 140 characters

The current version does not check for length and will send your message to Twitter. Twitter will respond with an error.

Does this plugin support URL shortening?

Version 0.1 does not support URL shortening.

Does maven execution stop if the Twitter Plugin fails

No. All errors are logged, but no Exception is thrown.

Is there a limit to how many messages I can send?

Yes. Twitter has a rate limit of 150 message per hour. See details.

What are all the different Maven phases

Here’s Maven’s documentation on Phases

Reference

Related posts:

  1. How to automate project versioning and release with Maven
  2. How to auto-generate Maven plugin documentation
  3. Maven Cargo JBoss
  4. 3 ways to run Java main from Maven
  5. The plugin ‘org.codehaus.mojo:selenium-maven-plugin’ does not exist or no valid version could be found

4 comments to Tweet your builds with Maven Twitter Plugin

  • Hi Vineet,
    Because of this post I developed an Ant twitter task (http://wap.ecw.de/archives/1232) which allows you to send messages with more than 140 chars and bit.ly support.
    You can use my source code to improve your mavent-twitter-plugin. Hail to open source ;)

  • Kristine Shuee

    - i just love to Twitter everyday with my friends. Twitter is much better than blogging in my opinion and it is very addictive too.
    **** ..

  • Caramoan

    Twitter is some ways is much better than blogging. I love to Twitter my everyday activities on my friends and relatives.
    ***

  • Zachery Fenoglio

    I love to use Twitter whenever i want to know the latest buzz about my friends. I also use Twitter to know the latest buzz from famous persons “

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes