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

Figure 23.1. Java plugin - tasks

23.4. Project layout

The Java plugin assumes the project layout shown below. None of these directories need exist or have anything in them. The Java plugin will compile whatever it finds, and handles anything which is missing.

Table 23.4. Java plugin - default project layout

Directory

Meaning

src/main/java

Production Java source

src/main/resources

Production resources

src/test/java

Test Java source

src/test/resources

Test resources

src/sourceSet/java

Java source for the given source set

src/sourceSet/resources

Resources for the given source set

23.4.1. Changing the project layout

You configure the project layout by configuring the appropriate source set. This is discussed in more detail in the following sections. Here is a brief example which changes the main Java and resource source directories.

Example 23.2. Custom Java source layout

build.gradle

sourceSets { main {

java {

srcDir 'src/java'

}

resources {

srcDir 'src/resources'

}

}

}

Page 140 of 343

23.5. Dependency management

The Java plugin adds a number of dependency configurations to your project, as shown below. It assigns those configurations to tasks such as compileJava and test.

Table 23.5. Java plugin - dependency configurations

Name

Extends

Used by tasks

Meaning

compile

-

compileJava

Compile time dependencies

runtime

compile

-

Runtime dependencies

testCompile

compile

compileTestJava

Additional dependencies for compiling

 

 

 

tests.

testRuntime

runtime,

test

Additional dependencies for running tests

 

testCompile

 

only.

archives

-

uploadArchives

Artifacts (e.g. jars) produced by this

 

 

 

project.

default

runtime

-

The default configuration used by a project

 

 

 

dependency on this project. Contains the

 

 

 

artifacts and dependencies required by this

 

 

 

project at runtime.

Figure 23.2. Java plugin - dependency configurations

For each source set you add to the project, the Java plugins adds the following dependency configurations:

Table 23.6. Java plugin - source set dependency configurations

Name

Extends

Used by tasks

Meaning

sourceSet

-

compile

Compile time dependencies for the

Compile

 

SourceSetJava

given source set

sourceSet

sourceSet

-

Runtime time dependencies for the

Runtime

Compile

 

given source set

Page 141 of 343

23.6. Convention properties

The Java plugin adds a number of convention properties to the project, shown below. You can use these properties in your build script as though they were properties of the project object (see Section 21.3, “Conventions”).

Table 23.7. Java plugin - directory properties

Property name

Type

Default value

Description

reportsDirName

String

reports

The name of

 

 

 

the directory

 

 

 

to generate

 

 

 

reports into,

 

 

 

relative to the

 

 

 

build directory.

reportsDir

File

buildDir/reportsDirName

The directory

 

(read-only)

 

to generate

 

 

 

reports into.

testResultsDirName

String

test-results

The name of

 

 

 

the directory

 

 

 

to generate

 

 

 

test result .xml

 

 

 

files into,

 

 

 

relative to the

 

 

 

build directory.

testResultsDir File

(read-only)

buildDir/testResultsDirNameThe directory to generate test result .xml files into.

testReportDirName

String

tests

The name of

 

 

 

the directory

 

 

 

to generate

 

 

 

the test report

 

 

 

into, relative to

 

 

 

the reports

 

 

 

directory.

testReportDir

File

reportsDir/testReportDirNameThe directory

 

(read-only)

 

to generate

 

 

 

the test report

 

 

 

into.

Page 142 of 343

libsDirName

String

libs

The name of

 

 

 

the directory

 

 

 

to generate

 

 

 

libraries into,

 

 

 

relative to the

 

 

 

build directory.

libsDir

File

buildDir/libsDirName

The directory

 

(read-only)

 

to generate

 

 

 

libraries into.

distsDirName

String

distributions

The name of

 

 

 

the directory

 

 

 

to generate

 

 

 

distributions

 

 

 

into, relative to

 

 

 

the build

 

 

 

directory.

distsDir

File

buildDir/distsDirName

The directory

 

(read-only)

 

to generate

 

 

 

distributions

 

 

 

into.

docsDirName

String

docs

The name of

 

 

 

the directory

 

 

 

to generate

 

 

 

documentation

 

 

 

into, relative to

 

 

 

the build

 

 

 

directory.

docsDir

File

buildDir/docsDirName

The directory

 

(read-only)

 

to generate

 

 

 

documentation

 

 

 

into.

dependencyCacheDirName

String

dependency-cache

The name of

 

 

 

the directory

 

 

 

to use to

 

 

 

cache source

 

 

 

dependency

 

 

 

information,

 

 

 

relative to the

 

 

 

build directory.

dependencyCacheDir

File

buildDir/dependencyCacheDirNameThe directory

 

(read-only)

 

to use to

 

 

 

cache source

 

 

 

dependency

 

 

 

information.

Page 143 of 343

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