Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Gradle.pdf
Скачиваний:
9
Добавлен:
24.03.2015
Размер:
1.4 Mб
Скачать

Example 40.3. Using the announce plugin

build.gradle

task helloWorld << { ant.echo(message: "hello")

}

helloWorld.doLast {

announce("Build complete", "notify-send") announce("Build complete", "twitter")

}

As you can see, the syntax in .doLast is

announce("MESSAGE", "TARGET")

Where MESSAGE is any GString you pass (and might have constructed before). And TARGET might one of the following:

Table 40.1. announce plugin targets

target

target

configuration more information

literal

 

parameters

twitter

Twitter

username ,

 

 

password

snarl

Snarl

 

 

Windows

 

 

Notification

 

 

Service

 

growl

Growl Mac

 

 

OS X

 

 

Notification

 

 

Service

 

notify-send

Notify

You need to have notify-send installed for

 

Ubuntu

this. Run sudo apt-get install libnoti

 

Notification

on Ubuntu to install it.

 

Service

 

40.2. Tasks

TBD

40.3. Project layout

TBD

Page 209 of 343

40.4. Dependency management

TBD

40.5. Convention properties

The announce plugin adds an TBD

TBD

Page 210 of 343

41

The Build Announcements Plugin

The build announcements is experimental and should not be considered stable.

The build announcements plugin uses the announce plugin to send local announcements on important events in the build.

41.1. Usage

To use the build announcements plugin, include in your build script:

Example 41.1. Using the build announcements plugin

build.gradle

apply plugin: 'build-announcements'

That's it. If you want to tweak where the announcements go, you can configure theannounce plugin to change the local announcer.

You can also apply the plugin from an init script:

Example 41.2. Using the build announcements plugin from an init script

init.gradle

rootProject {

apply plugin: 'build-announcements'

}

Page 211 of 343

42

The Application Plugin

The Gradle application plugin extends the language plugins with common application related tasks. It allows running and bundling applications for the jvm.

42.1. Usage

To use the application plugin, include in your build script:

Example 42.1. Using the application plugin

build.gradle

apply plugin:'application'

To define the main-class for the application you have to set the mainClassName property as shown below

Example 42.2. Configure the application main class

build.gradle

mainClassName = "org.gradle.sample.Main"

Then, you can run the application by running gradle run. Gradle will take care of building the application classes, along with their runtime dependencies, and starting the application with the correct classpath.

The plugin can also build a distribution for your application. The distribution will package up the runtime dependencies of the application along with some OS specific start scripts. All files stored in src/dist will be added to the root of the distribution. You can run gradle installApp to create an image of the application in build/install/projectName. You can run gradle dis to create a ZIP containing the distribution.

Page 212 of 343

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]