Gradle 2.0 用户指南翻译——第四十二章. 公告插件

本文禁止w3cschool转载!

翻译项目请关注Github上的地址:https://github.com/msdx/gradledoc 。

本文翻译所在分支:https://github.com/msdx/gradledoc/tree/2.0 。
更好的阅读体验请访问:http://gradledoc.githang.com/2.0/userguide/userguide.html 。
另外,Android 手机用户可通过我写的一个程序浏览文档,带缓存功能的,目前0.6.1版本兼容 Android 4.0.3以上系统,项目地址如下:
https://github.com/msdx/gradle-doc-apk

翻译不易,本文采用 CC BY-NC-SA 4.0 许可协议,转载请务必署名及注明本文在CSDN博客上的出处:

https://coder.blog.csdn.net/article/details/90716023

关于我对Gradle的翻译,以Github上的项目及http://gradledoc.githang.com 上的文档为准。如发现翻译有误的地方,将首先在以上两个地方更新。因时间精力问题,博客中发表的译文基本不会同步修改。

第四十二章. 公告插件

Chapter 42. The Announce Plugin

Gradle 公告允许在构建期间发送自定义通知,它支持以下通知系统: 
The Gradle announce allows to send custom announcements during a build. The following notification systems are supported:

 

42.1. 用法

42.1. Usage

要使用公告插件,请在构建脚本中应用它:
To use the announce plugin, apply it to your build script:

示例 42.1. 使用公告插件 - 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. 配置公告插件 - Example 42.2. Configure the announce plugin

build.gradle

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

最后,使用announce方法发送公告:
Finally, send announcements with the announce method:

 

示例 42.3. 使用公告插件 - 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. 公告插件通知服务 - Table 42.1. Announce Plugin Notification Services

通知服务
Notification Service
操作系统
Operating System
配置属性
Configuration Properties
补充信息
Further Information
twitter任意
Any
username, password 
snarlWindows  
growlMac OS X  
notify-sendUbuntu 需要安装notify-send软件包。可以使用sudo apt-get install libnotify-bin来安装它。
Requires the notify-send package to be installed. Use sudo apt-get install libnotify-bin to install it.
localWindows, Mac OS X, Ubuntu 根据当前的操作系统在 snarl,growl和notify-send之间自动选择。
Automatically chooses between snarl, growl, and notify-send depending on the current operating system.

42.2. 配置

42.2. Configuration

请参阅 AnnouncePluginExtension
See AnnouncePluginExtension.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值