A Configuration
represents a group of artifacts and their dependencies.Configuration is an instance of a FileCollection
that contains all dependencies
Property details
boolean
transitive
The transitivity of this configuration. A transitive configuration contains the transitive closure of its direct dependencies, and all their(direct dependencies') dependencies. An intransitive configuration contains only the direct dependencies. The default value is true.
PublishArtifactSet
allArtifacts
(read-only)
The artifacts of this configuration including the artifacts of extended configurations.
PublishArtifactSet
artifacts
(read-only)
The artifacts of this configuration excluding the artifacts of extended configurations.
Set
<Configuration
>
extendsFrom
Set
<Configuration
>The names of the configurations which this configuration extends from. The artifacts of the super configurations are also available in this configuration.
DependencySet
allDependencies
(read-only) —— 不包括传递性的依赖
Gets the complete set of declared dependencies including those contributed by superconfigurations.
This method does not resolve(解析) the configuration. Therefore, the return value does not include transitive dependencies.
DependencySet
dependencies
(read-only)
Gets the set of declared dependencies directly contained in this configuration (ignoring superconfigurations).
This method does not resolve the configuration. Therefore, the return value does not include transitive dependencies.
superconfigurations ; extended configurations 继承关系的configuration? : compile project(':library')
TaskDependency
buildDependencies
(read-only)
Returns a TaskDependency
object containing all required dependencies to build the local dependencies (e.g. project dependencies) belonging to this configuration or to one of its super configurations.
A TaskDependency
represents an unordered set of tasks which a Task
depends on. Gradle ensures that all the dependencies of a task are executed before the task itself is executed.
String
description
The description for this configuration.
String
name
(read-only)
The name of this configuration.
Set
<ExcludeRule
>
excludeRules
(read-only)
Set
<ExcludeRule
>The exclude rules applied for resolving any dependency of this configuration.
Set
<Configuration
>
hierarchy
(read-only) —— 有序递归的
Set
<Configuration
>Gets a ordered set including this configuration and all superconfigurations recursively.
ResolvableDependencies
incoming
(read-only) —— 可解析的
The incoming dependencies of this configuration.
- 依赖该包(包含的类)的外部包(类)(i.e. incoming dependencies)
- 被该包依赖的外部包(i.e. outgoing dependencies)
ResolvedConfiguration
resolvedConfiguration
(read-only) —— 已解析的
Resolves this configuration. This locates and downloads the files which make up this configuration, and returns a ResolvedConfiguration
that may be used to determine information about the resolve (including errors).
A ResolvedConfiguration
represents the result of resolving a Configuration
, and provides access to both the artifacts and the meta-data of the result.
ResolutionStrategy
resolutionStrategy
(read-only) —— 异常等的解决方案(策略)
The resolution strategy used by this configuration. The resolution strategy provides extra details on how to resolve this configuration. See docs for ResolutionStrategy
for more info and examples.
Defines the strategies around dependency resolution. For example, forcing certain dependency versions, substitutions, conflict resolutions or snapshot timeouts.
State
state
(read-only)
The states a configuration can be into。A configuration is only mutable(易于改变的) as long as it is in the unresolved state。
public static final Configuration.State UNRESOLVED
public static final Configuration.State RESOLVED
public static final Configuration.State RESOLVED_WITH_FAILURES
Configuration
copy
()
Creates a copy of this configuration that only contains the dependencies directly in this configuration (without contributions from superconfigurations). The new configuration will be in the UNRESOLVED state, but will retain all other attributes of this configuration except superconfigurations. Configuration.getHierarchy()
for the copy will not include any superconfigurations.
Configuration
copyRecursive
() —— configuration和attributes
Creates a copy of this configuration that contains the dependencies directly in this configuration and those derived from superconfigurations. The new configuration will be in the UNRESOLVED state, but will retain all other attributes of this configuration except superconfigurations. Configuration.getHierarchy()
for the copy will not include any superconfigurations.
Configuration
copy
(Closure
dependencySpec)
Takes a closure which gets coerced into a Spec
. Behaves otherwise in the same way as Configuration.copy(org.gradle.api.specs.Spec)
Configuration
copyRecursive
(Closure
dependencySpec)
Takes a closure which gets coerced into a Spec
. Behaves otherwise in the same way as Configuration.copyRecursive(org.gradle.api.specs.Spec)
Configuration
copy
(Spec
<? super Dependency
>
dependencySpec)
Spec
<? super Dependency
>Creates a copy of this configuration ignoring superconfigurations (see Configuration.copy()
but filtering the dependencies using the specified dependency spec.
Configuration
copyRecursive
(Spec
<? super Dependency
>
dependencySpec)
Spec
<? super Dependency
>Creates a copy of this configuration with dependencies from superconfigurations (see Configuration.copyRecursive()
) but filtering the dependencies using the dependencySpec.
Spec ??
Spec ??
Configuration
defaultDependencies
(Action
<? super DependencySet
>
action)
Action
<? super DependencySet
>Note: This method is incubating(在孵化的) and may change in a future version of Gradle.
Execute the given action if the configuration has no defined dependencies when it first participates in dependency resolution.
A Configuration
will participate in dependency resolution when:
- The
Configuration
itself is resolved - Another
Configuration
that extends this one is resolved - Another
Configuration
that references this one as a project dependency is resolved
This method is useful for specifying default dependencies for a configuration:
configurations { conf }
configurations['conf'].defaultDependencies {
dependencies -> dependencies.add(owner.project.dependencies.create("org.gradle:my-util:1.0")) —— action
}
A Configuration
is considered empty even if it extends another, non-empty Configuration
.—— 即使extends另一个非空Configuration
,如果没有define dependencies,扔会被认为是空
If multiple actions are supplied, each action will be executed until the set of dependencies is no longer empty. Remaining actions will be ignored.——多个action时,每一个action都会被执行,直到Configuration不为空。余下未执行的action会被忽略
Configuration
exclude
(Map
<String
, String
>
excludeProperties)
Map
<String
, String
>Adds an exclude rule to exclude transitive dependencies for all dependencies of this configuration. You can also add exclude rules per-dependency. See ModuleDependency.exclude(java.util.Map)
.
Configuration
extendsFrom
(Configuration
...
superConfigs)
Configuration
...Adds the given configurations to the set of configuration which this configuration extends from.
FileCollection
fileCollection
(Closure
dependencySpecClosure)
Takes a closure which gets coerced into a Spec
. Behaves otherwise in the same way asConfiguration.fileCollection(org.gradle.api.specs.Spec)
.
FileCollection
fileCollection
(Dependency
...
dependencies)
Dependency
...Resolves this configuration lazily. The resolve happens when the elements of the returned FileCollection
get accessed the first time. This locates and downloads the files which make up this configuration. Only the resulting set of files belonging to specified dependencies is contained in the FileCollection.
FileCollection
fileCollection
(Spec
<? super Dependency
>
dependencySpec)
Spec
<? super Dependency
>Resolves this configuration lazily. The resolve happens when the elements of the returned FileCollection
get accessed the first time. This locates and downloads the files which make up this configuration. Only the resulting set of files belonging to the subset of dependencies specified by the dependencySpec is contained in the FileCollection.
Closure
dependencySpecClosure);Dependency
...
dependencies;Spec
<? super Dependency
>
dependencySpec) ????
Dependency
...Spec
<? super Dependency
>Takes a closure which gets coerced into a Spec
. Behaves otherwise in the same way asConfiguration.files(org.gradle.api.specs.Spec)
.
Set
<File
>
files
(Dependency
...
dependencies)
Set
<File
>Dependency
...Resolves this configuration. This locates and downloads the files which make up this configuration. But only the resulting set of files belonging to the specified dependencies is returned.
Set
<File
>
files
(Spec
<? super Dependency
>
dependencySpec)
Set
<File
>Spec
<? super Dependency
>Resolves this configuration. This locates and downloads the files which make up this configuration. But only the resulting set of files belonging to the subset of dependencies specified by the dependencySpec is returned.
TaskDependency
getTaskDependencyFromProjectDependency
(boolean
useDependedOn, String
taskName)
Returns a TaskDependency object containing dependencies on ( all tasks with the specified name from (project dependencies related to this configuration)or (one of its super configurations)).
These other projects may be projects (this configuration depends on) or projects (with a similarly named configuration that depend on this one) based on the useDependOn argument.