| API文档: | ArtifactResolutionQuery |
|---|
用于构造查询的构建器,该查询可以解析指定组件的选定软件工件。
plugins {
id 'java'
}
task resolveCompileSources {
doLast {
def componentIds = configurations.compileClasspath.incoming.resolutionResult.allDependencies.collect { it.selected.id }
def result = dependencies.createArtifactResolutionQuery()
.forComponents(componentIds)
.withArtifacts(JvmLibrary, SourcesArtifact, JavadocArtifact)
.execute()
for (component in result.resolvedComponents) {
component.getArtifacts(SourcesArtifact).each { println "Source artifact for ${component.id}: ${it.file}" }
}
}
}
| 方法 | 描述 |
execute() | 实际执行查询,返回查询结果。请注意, |
forComponents(componentIds) | 指定要包含在结果中的组件集。 |
forComponents(componentIds) | 指定要包含在结果中的组件集。 |
forModule(group, name, version) | 使用其 GAV 坐标指定要包含在结果中的模块组件。 |
withArtifacts(componentType, artifactTypes) | 定义结果中预期的组件类型,以及要检索该类型组件的工件。目前,仅允许单一组件类型和工件集。 |
withArtifacts(componentType, artifactTypes) | 定义结果中预期的组件类型,以及要检索该类型组件的工件。目前,仅允许单一组件类型和工件集。 |
ArtifactResolutionResult execute()
实际执行查询,返回查询结果。请注意,ArtifactResolutionQuery.withArtifacts(java.lang.Class, java.lang.Class[])必须在执行查询之前调用。
ArtifactResolutionQuery forComponents(组件 ID)Iterable<? extends ComponentIdentifier>
Iterable<? extends ComponentIdentifier>指定要包含在结果中的组件集。
ArtifactResolutionQuery forComponents(ComponentIdentifier...组件 ID)
ComponentIdentifier...指定要包含在结果中的组件集。
ArtifactResolutionQuery forModule(String组、String名称、String版本)
使用其 GAV 坐标指定要包含在结果中的模块组件。
ArtifactResolutionQuery withArtifacts(组件类型,工件类型)Class<? extends Component>Class<? extends Artifact>...
Class<? extends Component>Class<? extends Artifact>...定义结果中预期的组件类型,以及要检索该类型组件的工件。目前,仅允许单一组件类型和工件集。
ArtifactResolutionQuery withArtifacts(组件类型,工件类型)Class<? extends Component>Collection<Class<? extends Artifact>>
Class<? extends Component>Collection<Class<? extends Artifact>>定义结果中预期的组件类型,以及要检索该类型组件的工件。目前,仅允许单一组件类型和工件集。