Chapter 38. The Announce Plugin

Table of Contents

38.1. Usage
38.2. Configuration

The Gradle announce plugin allows you to send custom announcements during a build. The following notification systems are supported:

38.1. Usage

To use the announce plugin, apply it to your build script:

Example 38.1. Using the announce plugin

build.gradle

apply plugin: 'announce'

Next, configure your notification service(s) of choice (see table below for which configuration properties are available):

Example 38.2. Configure the announce plugin

build.gradle

announce {  
  username = 'myId'
  password = 'myPassword'
}

Finally, send announcements with the announce method:

Example 38.3. Using the announce plugin

build.gradle

task helloWorld {
    doLast {
        println "Hello, world!"
    }
}  

helloWorld.doLast {  
    announce.announce("helloWorld completed!", "twitter")
    announce.announce("helloWorld completed!", "local")
}

The announce method takes two String arguments: The message to be sent, and the notification service to be used. The following table lists supported notification services and their configuration properties.

Table 38.1. Announce Plugin Notification Services

Notification Service Operating System Configuration Properties Further Information
twitter Any username, password
snarl Windows
growl Mac OS X
notify-send Ubuntu Requires the notify-send package to be installed. Use sudo apt-get install libnotify-bin to install it.
local Windows, Mac OS X, Ubuntu Automatically chooses between snarl, growl, and notify-send depending on the current operating system.

38.2. Configuration

See the AnnouncePluginExtension class in the API documentation.