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

27.7. Customizing

Here is an example with the most important customization options:

Example 27.2. Customization of ear plugin

build.gradle

apply plugin: 'ear' apply plugin: 'java'

repositories { mavenCentral() }

dependencies {

//following dependencies will become the ear modules and placed in the ear deploy project(':war')

//following dependencies will become ear libs and placed in a dir configur earlib group: 'log4j', name: 'log4j', version: '1.2.15', ext: 'jar'

}

ear {

appDirName 'src/main/app' // use application metadata found in this folde libDirName 'APP-INF/lib' // put dependency libraries into APP-INF/lib ins // also modify the generated deployment descri

deploymentDescriptor { // custom entries for application.xml:

//fileName = "application.xml" // same as the default value

//version = "6" // same as the default value applicationName = "customear" initializeInOrder = true

displayName = "Custom Ear" // defaults to project.name

description = "My customized EAR for the Gradle documentation" // def

//libraryDirectory = "APP-INF/lib" // not needed, because setting libDi

//module("my.jar", "java") // wouldn't deploy since my.jar isn't a depl

//webModule("my.war", "/") // wouldn't deploy since my.war isn't a depl securityRole "admin"

securityRole "superadmin"

withXml { provider -> // add a custom node to the XML provider.asNode().appendNode("data-source", "my/data/source")

}

}

}

You can also use customization options that the Ear task provides, such as from and metaInf.

27.8. Using custom descriptor file

Let's say you already have theapplication.xml and want to use it instead of configuring the ea section. To accommodate that place the META-INF/application.xml in the right place inside your source folders (see the appDirName property). The existing file contents will be used and the explicit configuration in the ear.deploymentDescriptor will be ignored.

Page 172 of 343

28

The Jetty Plugin

The Jetty plugin extends the War plugin to add tasks which allow you to deploy your web application to a Jetty web container embedded in the build.

28.1. Usage

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

Example 28.1. Using the Jetty plugin

build.gradle

apply plugin: 'jetty'

28.2. Tasks

The Jetty plugin defines the following tasks:

Table 28.1. Jetty plugin - tasks

Task name

Depends

Type

Description

 

on

 

 

jettyRun

compile

JettyRun

Starts a Jetty instance and deploys the

 

 

 

exploded web application to it.

jettyRunWar

war

JettyRunWar

Starts a Jetty instance and deploys the WAR

 

 

 

to it.

jettyStop

-

JettyStop

Stops the Jetty instance.

Page 173 of 343

Figure 28.1. Jetty plugin - tasks

28.3. Project layout

The Jetty plugin uses the same layout as the War plugin.

28.4. Dependency management

The Jetty plugin does not define any dependency configurations.

28.5. Convention properties

The Jetty plugin defines the following convention properties:

Table 28.2. Jetty plugin - properties

Property

Type

Default

Description

name

 

value

 

httpPort

Integer

8080

The TCP port which Jetty should listen for HTTP

 

 

 

requests on.

stopPort

Integer

null

The TCP port which Jetty should listen for admin

 

 

 

requests on.

stopKey

String

null

The key to pass to Jetty when requesting it to

 

 

 

stop.

These properties are provided by a JettyPluginConvention convention object.

Page 174 of 343

29

The Checkstyle Plugin

The Checkstyle plugin performs quality checks on your project's Java source files usingCheckstyle and generates reports from these checks.

29.1. Usage

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

Example 29.1. Using the Checkstyle plugin

build.gradle

apply plugin: 'checkstyle'

The plugin adds a number of tasks to the project that perform the quality checks. You can execute the checks by running gradle check.

29.2. Tasks

The Checkstyle plugin adds the following tasks to the project:

Table 29.1. Checkstyle plugin - tasks

Task name

Depends on

Type

Description

checkstyleMain

classes

Checkstyle

Runs Checkstyle against the

 

 

 

production Java source files.

checkstyleTest testClasses Checkstyle

checkstyleSourceSetsourceSetClassCheckstylees

Runs Checkstyle against the test Java source files.

Runs Checkstyle against the given source set's Java source files.

The Checkstyle plugin adds the following dependencies to tasks defined by the Java plugin.

Page 175 of 343

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