|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD |
public interface DependencyHandler
A DependencyHandler is used to declare artifact dependencies. Artifact dependencies are grouped into configurations (see Configuration).
To declare a specific dependency for a configuration you can use the following syntax:
dependencies { configurationName dependencyNotation1, dependencyNotation2, ... }
or, to configure a dependency when it is declared, you can additionally pass a configuration closure:
dependencies { configurationName dependencyNotation { configStatement1 configStatement2 } }
There are several supported dependency notations. These are described below. For each dependency declared this way, a Dependency object is created. You can use this object to query or further configure the dependency.
You can also always add instances of Dependency directly:
configurationName <instance>
There are 2 notations supported for declaring a dependency on an external module. One is a string notation:
configurationName "group:name:version:classifier"
The other is a map notation:
configurationName group: group:, name: name, version: version, classifier:
classifier
In both notations, all properties, except name, are optional.
External dependencies are represented by a ExternalModuleDependency.
To add a client module to a configuration you can use the notation:
configurationName module(moduleNotation) { module dependencies }The module notation is the same as the dependency notations described above, except that the classifier property is not available. Client modules are represented using a ClientModule.
To add a project dependency, you use the following notation
configurationName project(':someProject')
Project dependencies are represented using a ProjectDependency.
You can also add a dependency using a FileCollection:
configurationName files('a file')
File dependencies are represented using a SelfResolvingDependency.
You can add a dependency using a Configuration.
When the configuration is from the same project as the target configuration, the target configuration is changed to extend from the provided configuration.
When the configuration is from a different project, a project dependency is added.
Method Summary | |
---|---|
Dependency
|
add(java.lang.String configurationName, java.lang.Object dependencyNotation)
Adds a dependency to the given configuration. |
Dependency
|
add(java.lang.String configurationName, java.lang.Object dependencyNotation, groovy.lang.Closure configureClosure)
Adds a dependency to the given configuration, and configures the dependency using the given closure. |
Dependency
|
create(java.lang.Object dependencyNotation)
Creates a dependency without adding it to a configuration. |
Dependency
|
create(java.lang.Object dependencyNotation, groovy.lang.Closure configureClosure)
Creates a dependency without adding it to a configuration, and configures the dependency using the given closure. |
Dependency
|
gradleApi()
Creates a dependency on the API of the current version of Gradle. |
Dependency
|
localGroovy()
Creates a dependency on the Groovy that is distributed with the current version of Gradle. |
Dependency
|
module(java.lang.Object notation)
Creates a dependency on a client module. |
Dependency
|
module(java.lang.Object notation, groovy.lang.Closure configureClosure)
Creates a dependency on a client module. |
Dependency
|
project(java.util.Map notation)
Creates a dependency on a project. |
Method Detail |
---|
public Dependency add(java.lang.String configurationName, java.lang.Object dependencyNotation)
configurationName
- The name of the configuration.dependencyNotation
- The dependency notation, in one of the notations described above.
public Dependency add(java.lang.String configurationName, java.lang.Object dependencyNotation, groovy.lang.Closure configureClosure)
configurationName
- The name of the configuration.dependencyNotation
- The dependency notation, in one of the notations described above.configureClosure
- The closure to use to configure the dependency.
public Dependency create(java.lang.Object dependencyNotation)
dependencyNotation
- The dependency notation, in one of the notations described above.
public Dependency create(java.lang.Object dependencyNotation, groovy.lang.Closure configureClosure)
dependencyNotation
- The dependency notation, in one of the notations described above.configureClosure
- The closure to use to configure the dependency.
public Dependency gradleApi()
public Dependency localGroovy()
public Dependency module(java.lang.Object notation)
notation
- The module notation, in one of the notations described above.
public Dependency module(java.lang.Object notation, groovy.lang.Closure configureClosure)
notation
- The module notation, in one of the notations described above.configureClosure
- The closure to use to configure the dependency.
public Dependency project(java.util.Map notation)
notation
- The project notation, in one of the notations described above.
Groovy Documentation