注意:此类正在孵化中,可能会在 Gradle 的未来版本中发生更改。
收集依赖项Configuration
、依赖项约束和排除规则。
财产 | 描述 |
allArtifacts | 此配置的工件包括扩展配置的工件。 |
allDependencies | 获取完整的声明依赖项集,包括由超级配置贡献的依赖项。 |
artifacts | 此配置的工件不包括扩展配置的工件。 |
buildDependencies | 返回一个 |
dependencies | 获取直接包含在此配置中的声明的依赖项集(忽略超级配置)。 |
description | 此配置的说明。 |
excludeRules | 排除规则适用于解决此配置的任何依赖性。 |
extendsFrom | 此配置扩展自的配置的名称。超级配置的神器在这个配置里也有。 |
hierarchy | 递归获取包含此配置和所有超级配置的有序集。 |
incoming | 此配置的传入依赖项。 |
resolutionStrategy | 此配置使用的解析策略。解决策略提供了有关如何解决此配置的额外详细信息。 |
resolvedConfiguration | 解决此配置。这将查找并下载构成此配置的文件,并返回 |
state | 配置的状态。 |
transitive | 此配置的传递性。传递配置包含其直接依赖项及其所有依赖项的传递闭包。不传递配置仅包含直接依赖项。默认值是true。 |
visible | 如果这是可见配置,则返回 true。可见配置可以在其所属项目之外使用。默认值是true。 |
方法 | 描述 |
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.
|
copy(dependencySpec) | Takes a closure which gets coerced into a |
copy(dependencySpec) | Creates a copy of this configuration ignoring superconfigurations (see |
copyRecursive() | 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.
|
copyRecursive(dependencySpec) | Takes a closure which gets coerced into a |
copyRecursive(dependencySpec) | Creates a copy of this configuration with dependencies from superconfigurations (see |
defaultDependencies(action) | Execute the given action if the configuration has no defined dependencies when it first participates in
dependency resolution. A |
exclude(excludeProperties) | Adds an exclude rule to exclude transitive dependencies for all dependencies of this configuration.
You can also add exclude rules per-dependency. See |
extendsFrom(superConfigs) | Adds the given configurations to the set of configuration which this configuration extends from. |
fileCollection(dependencySpecClosure) | Takes a closure which gets coerced into a |
fileCollection(dependencies) | Resolves this configuration lazily. The resolve happens when the elements of the returned |
fileCollection(dependencySpec) | Resolves this configuration lazily. The resolve happens when the elements of the returned |
files(dependencySpecClosure) | Takes a closure which gets coerced into a |
files(dependencies) | 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. |
files(dependencySpec) | 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. |
getTaskDependencyFromProjectDependency(useDependedOn, 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. |
PublishArtifactSet
allArtifacts
(read-only)
The artifacts of this configuration including the artifacts of extended configurations.
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.
PublishArtifactSet
artifacts
(read-only)
The artifacts of this configuration excluding the artifacts of extended configurations.
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.
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.
String
description
The description for this configuration.
Set
<ExcludeRule
>
excludeRules
(read-only)
Set
<ExcludeRule
>The exclude rules applied for resolving any dependency of this configuration.
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.
Set
<Configuration
>
hierarchy
(read-only)
Set
<Configuration
>Gets an ordered set including this configuration and all superconfigurations recursively.
ResolvableDependencies
incoming
(read-only)
The incoming dependencies of this configuration.
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.
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).
The transitivity of this configuration. A transitive configuration contains the transitive closure of its direct dependencies, and all their dependencies. An intransitive configuration contains only the direct dependencies. The default value is true.
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.
This method is only intended for use for specific situations involving resolvable configuration, it is NOT intended as a general-purpose copying mechanism.
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)
This method is only intended for use for specific situations involving resolvable configuration, it is NOT intended as a general-purpose copying mechanism.
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.
This method is only intended for use for specific situations involving resolvable configuration, it is NOT intended as a general-purpose copying mechanism.
Configuration
copyRecursive
()
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.
This method is only intended for use for specific situations involving resolvable configuration, it is NOT intended as a general-purpose copying mechanism.
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)
This method is only intended for use for specific situations involving resolvable configuration, it is NOT intended as a general-purpose copying mechanism.
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.
This method is only intended for use for specific situations involving resolvable configuration, it is NOT intended as a general-purpose copying mechanism.
Configuration
defaultDependencies
(Action
<? super DependencySet
>
action)
Action
<? super DependencySet
>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")) }
A Configuration
is considered empty even if it extends another, non-empty Configuration
.
If multiple actions are supplied, each action will be executed until the set of dependencies is no longer empty. Remaining actions will be ignored.
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 as
Configuration.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.
Takes a closure which gets coerced into a Spec
. Behaves otherwise in the same way as
Configuration.files(org.gradle.api.specs.Spec)
.
Set
<File
>
files
(Dependency
...
dependencies)
Set
<File
>Dependency
...解决此配置。这将查找并下载构成此配置的文件。但仅返回属于指定依赖项的结果文件集。
Set
<File
>
files
(依赖规范)Spec
<? super Dependency
>
Set
<File
>Spec
<? super Dependency
>解决此配置。这将找到并下载构成此配置的文件。但仅返回属于 dependencySpec 指定的依赖项子集的结果文件集。
TaskDependency
getTaskDependencyFromProjectDependency
(boolean
useDependedOn,String
任务名称)
返回一个 TaskDependency 对象,其中包含与此配置或其超级配置之一相关的项目依赖项中具有指定名称的所有任务的依赖项。这些其他项目可能是此配置所依赖的项目,也可能是具有类似名称的配置(基于 useDependOn 参数依赖于此配置)的项目。