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

Example 24.3. Configuration of Groovy plugin

build.gradle

repositories { mavenCentral()

}

dependencies {

groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.7.10'

}

And here is an example using the Groovy JARs checked into the lib directory of the source tree:

Example 24.4. Configuration of Groovy plugin

build.gradle

repositories {

flatDir { dirs 'lib' }

}

dependencies {

groovy module(':groovy:1.6.0') { dependency('asm:asm-all:2.2.3') dependency('antlr:antlr:2.7.7') dependency('commons-cli:commons-cli:1.2') module(':ant:1.7.0') {

dependencies(':ant-junit:1.7.0:jar', ':ant-launcher:1.7.0')

}

}

}

24.5. Convention properties

The Groovy plugin does not add any convention properties to the project.

24.6. Source set properties

The Groovy plugin adds the following convention properties to each source set in the project. You can use these properties in your build script as though they were properties of the source set object (see Section 21.3, “Conventions”).

Page 159 of 343

Table 24.4. Groovy plugin - source set properties

Property name

Type

groovy SourceDirectorySet

(read-only)

groovy.srcDirs

Set<File>. Can set

 

using anything

 

described in

 

Section 18.5,

 

“Specifying a set of

 

input files”.

allGroovy

FileTree (read-only)

Default

Description

value

 

Not null

The Groovy source files of

 

this source set. Contains

 

all .groovy and .java

 

files found in the Groovy

 

source directories, and

 

excludes all other types of

 

files.

[projectDir/src/The sourcename/groovy]directories containing the Groovy source files of this source set. May also contain Java source files for joint compilation.

Not null

All Groovy source files of

 

this source set. Contains

 

only the .groovy files

 

found in the Groovy source

 

directories.

These properties are provided by a convention object of type GroovySourceSet.

The Groovy plugin also modifies some source set properties:

Table 24.5. Groovy plugin - source set properties

Property name

Change

allJava

Adds all .java files found in the Groovy source directories.

allSource

Adds all source files found in the Groovy source directories.

24.7. CompileGroovy

The Groovy plugin adds a GroovyCompile instance for each source set in the project. The task type extends the Compile task (see Section 23.11, “CompileJava”). The compile task delegates to the Ant Groovyc task to do the compile. Via the compile task you can set most of the properties of Ants Groovyc task.

Page 160 of 343

Table 24.6. Groovy plugin - CompileGroovy properties

Task Property

Type

classpath

FileCollection

source

FileTree. Can set using anything

 

described in Section 18.5, “Specifying a set

 

of input files”.

destinationDir

File.

groovyClasspath

FileCollection

Default Value

sourceSet.compileCl sourceSet.groovy

sourceSet.output.cl groovy configuration

[9] We don't recommend this, as the Groovy plugin uses theGroovyc Ant task to compile the sources. For pure Java projects you might rather stick with javac. In particular as you would have to supply a groovy jar for doing this.

[10] We are using the same conventions as introduced by Russel Winders Gant tool ( http://gant.codehaus.org).

Page 161 of 343

25

The Scala Plugin

The Scala plugin extends the Java plugin to add support for Scala projects. It can deal with Scala-only projects and with mixed Java/Scala projects. It can even deal with Java-only projects. The Scala plugin supports joint compilation of Java and Scala source. This means your project can contain Scala classes which use Java classes, and vice versa.

25.1. Usage

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

Example 25.1. Using the Scala plugin

build.gradle

apply plugin: 'scala'

25.2. Tasks

The Scala plugin adds the following tasks to the project.

Page 162 of 343

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