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

6 comments to Tweet your builds with Maven Twitter Plugin

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