Gradle 宣布允许在构建期间发送自定义公告。支持以下通知系统:
The Gradle announce allows to send custom announcements during a build. The following notification systems are supported:
要使用 announce 插件,请在构建脚本中包含以下语句:
To use the announce plugin, apply it to your build script:
示例 42.1. 使用 announce 插件 - Example 42.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):
示例 42.2. 配置 announce 插件 - Example 42.2. Configure the announce plugin
build.gradle
announce { username = 'myId' password = 'myPassword' }
最后,使用announce
方法发送公告:
Finally, send announcements with the announce
method:
示例 42.3. 使用 announce 插件 - Example 42.3. Using the announce plugin
build.gradle
task helloWorld << { println "Hello, world!" } helloWorld.doLast { announce.announce("helloWorld completed!", "twitter") announce.announce("helloWorld completed!", "local") }
announce
方法有两个 String 参数: 要被发送的消息,以及要使用的通知服务。下表列出了支持的通知服务以及它们的配置属性。
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.
表 42.1. Announce 插件通知服务 - Table 42.1. Announce Plugin Notification Services
通知服务 Notification Service |
操作系统 Operating System |
配置属性 Configuration Properties |
补充信息 Further Information |
任何 Any |
username, password | ||
snarl | Windows | ||
growl | Mac OS X | ||
notify-send | Ubuntu | 需要已安装通知发送包。使用 sudo apt-get install libnotify-bin 来安装它。Requires the notify-send package to be installed. Use sudo apt-get install libnotify-bin to install it. |
|
local | Windows, Mac OS X, Ubuntu | 根据当前的操作系统自动选择 snarl,growl,以及notify-send。 Automatically chooses between snarl, growl, and notify-send depending on the current operating system. |