api / org.gradle.api.artifacts.query / ArtifactResolutionQuery

ArtifactResolutionQuery

@Incubating interface ArtifactResolutionQuery

A builder to construct a query that can resolve selected software artifacts of the specified components.

 apply plugin: 'java' task resolveCompileSources { doLast { def componentIds = configurations.compile.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}" } } } } 

Since
2.0

Functions

execute

abstract fun execute(): ArtifactResolutionResult

Actually execute the query, returning a query result. Note that #withArtifacts(Class, Class[]) must be called before executing the query.

forComponents

abstract fun forComponents(componentIds: MutableIterable<ComponentIdentifier>): ArtifactResolutionQuery
abstract fun forComponents(vararg componentIds: ComponentIdentifier): ArtifactResolutionQuery

Specifies the set of components to include in the result.

forModule

abstract fun forModule(group: String, name: String, version: String): ArtifactResolutionQuery

Specifies a module component to include in the result using its GAV coordinates.

withArtifacts

abstract fun withArtifacts(componentType: Class<out Component>, vararg artifactTypes: Class<out Artifact>): ArtifactResolutionQuery
abstract fun withArtifacts(componentType: Class<out Component>, artifactTypes: MutableCollection<Class<out Artifact>>): ArtifactResolutionQuery

Defines the type of component that is expected in the result, and the artifacts to retrieve for components of this type. Presently, only a single component type and set of artifacts is permitted.