public interface 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}" }
}
}
}
| Modifier and Type | Method | Description |
|---|---|---|
ArtifactResolutionResult |
execute() |
Actually execute the query, returning a query result.
|
ArtifactResolutionQuery |
forComponents(java.lang.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 |
forModule(java.lang.String group,
java.lang.String name,
java.lang.String version) |
Specifies a module component to include in the result using its GAV coordinates.
|
ArtifactResolutionQuery |
withArtifacts(java.lang.Class<? extends Component> componentType,
java.lang.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.
|
ArtifactResolutionQuery |
withArtifacts(java.lang.Class<? extends Component> componentType,
java.util.Collection<java.lang.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.
|
ArtifactResolutionQuery forComponents(java.lang.Iterable<? extends ComponentIdentifier> componentIds)
componentIds - The identifiers of the components to be queried.ArtifactResolutionQuery forComponents(ComponentIdentifier... componentIds)
componentIds - The identifiers of the components to be queried.ArtifactResolutionQuery forModule(java.lang.String group, java.lang.String name, java.lang.String version)
group - Module group.name - Module name.version - Module version.ArtifactResolutionQuery withArtifacts(java.lang.Class<? extends Component> componentType, java.lang.Class<? extends Artifact>... artifactTypes)
componentType - The expected type of the component.artifactTypes - The artifacts to retrieve for the queried components.ArtifactResolutionQuery withArtifacts(java.lang.Class<? extends Component> componentType, java.util.Collection<java.lang.Class<? extends Artifact>> artifactTypes)
componentType - The expected type of the component.artifactTypes - The artifacts to retrieve for the queried components.ArtifactResolutionResult execute()
withArtifacts(Class, Class[]) must be called before executing the query.