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

Example 37.4. Export Dependencies

build.gradle

idea.module.iml { whenMerged { module ->

module.dependencies*.exported = true

}

}

37.4.2.3. Modifying the XML representation

The withXmlhook allows to manipulate the in-memory XML representation just before the file gets written to disk. Although Groovy's XML support makes up for a lot, this approach is less convenien than manipulating the domain objects. In return, you get total control over the generated file, including sections not modeled by the domain objects.

Example 37.5. Customizing the XML

build.gradle

idea.project.ipr { withXml { provider ->

provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.ma

}

}

37.5. Further things to consider

The paths of the dependencies in the generated IDEA files are absolute. If you manually define a path variable pointing to the Gradle dependency cache, IDEA will automatically replace the absolute dependency paths with this path variable. If you use such a path variable, you need to configure this path variable via idea.pathVariables, so that it can do a proper merge without creating duplicates.

Page 201 of 343

38

The Antlr Plugin

The Antlr plugin extends the Java plugin to add support for generating parsers using Antlr.

38.1. Usage

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

Example 38.1. Using the Antlr plugin

build.gradle

apply plugin: 'antlr'

38.2. Tasks

The Antlr plugin adds a number of tasks to your project, as shown below.

Table 38.1. Antlr plugin - tasks

 

 

 

Task name

Depends

Type

Description

 

on

 

 

generateGrammarSource

-

AntlrTask

Generates the source files

 

 

 

for all production Antlr

 

 

 

grammars.

generateTestGrammarSource

-

AntlrTask

Generates the source files

 

 

 

for all test Antlr grammars.

generateSourceSetGrammarSource-

AntlrTask

Generates the source files

 

 

 

for all Antlr grammars for the

 

 

 

given source set.

The Antlr plugin adds the following dependencies to tasks added by the Java plugin.

Page 202 of 343

Table 38.2. Antlr plugin - additional task dependencies

Task name

Depends on

compileJava

generateGrammarSource

compileTestJava

generateTestGrammarSource

compileSourceSetJava

generateSourceSetGrammarSource

38.3. Project layout

Table 38.3. Antlr plugin - project layout

Directory

Meaning

src/main/antlr

Production Antlr grammar files.

src/test/antlr

Test Antlr grammar files.

src/sourceSet/antlr

Antlr grammar files for the given source set.

38.4. Dependency management

The Antlr plugin adds an antlr dependency configuration. You use this to declare the version of

Antlr you wish to use.

Example 38.2. Declare Antlr version

build.gradle

repositories { mavenCentral()

}

dependencies {

antlr 'antlr:antlr:2.7.7'

}

38.5. Convention properties

The Antlr plugin does not add any convention properties.

38.6. Source set properties

The Antlr plugin adds the following properties to each source set in the project.

Page 203 of 343

Table 38.4. Antlr plugin - source set properties

Property name

Type

antlr SourceDirectorySet

(read-only)

antlr.srcDirs Set<File>. Can set

using anything described in Section 18.5, “Specifying a set of input files”.

Default

Description

value

 

Not null

The Antlr grammar files of

 

this source set. Contains all .g

 

found in the Antlr source

 

directories, and excludes all

 

other types of files.

[projectDir/src/The sourcename/antlr]directories containing the Antlr grammar files of this source set.

Page 204 of 343

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