A builder to construct a query that can resolve selected software artifacts of the specified components.
apply plugin: 'java'
task resolveCompileSources << {
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}" }
}
}
| Type | Name and description |
|---|---|
ArtifactResolutionResult |
execute()Actually execute the query, returning a query result. |
ArtifactResolutionQuery |
forComponents(Iterable<? extends ComponentIdentifier> componentIds)Specifies the set of components to include in the result. |
ArtifactResolutionQuery |
forComponents(ComponentIdentifier... componentIds)Specifies the set of components to include in the result. |
ArtifactResolutionQuery |
withArtifacts(Class<? extends Component> componentType, Class<? extends Artifact>... artifactTypes)Defines the type of component that is expected in the result, and the artifacts to retrieve for components of this type. |
Actually execute the query, returning a query result. Note that withArtifacts(Class, Class[]) must be called before executing the query.
Specifies the set of components to include in the result.
componentIds - The identifiers of the components to be queried.Specifies the set of components to include in the result.
componentIds - The identifiers of the components to be queried.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.
componentType - The expected type of the component.artifactTypes - The artifacts to retrieve for the queried components.