API 文件 | ArtifactResolutionQuery |
---|
用於建構查詢的建構器,該查詢可以解析指定組件的選定軟體 Artifact。
這是一個舊版 API,目前處於維護模式。在未來版本的 Gradle 中,此 API 將被棄用並移除。新程式碼不應使用此 API。解析來源和 javadoc 時,請優先使用 <UNHANDLED-LINK>ArtifactView.ViewConfiguration#withVariantReselection()</UNHANDLED-LINK>。
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}" } } } }
方法 | 描述 |
執行() | 實際執行查詢,並傳回查詢結果。請注意,在執行查詢之前,必須先呼叫 |
forComponents(componentIds) | 指定要包含在結果中的組件集合。 |
forComponents(componentIds) | 指定要包含在結果中的組件集合。 |
forModule(group, name, version) | 使用其 GAV 座標指定要包含在結果中的模組組件。 |
withArtifacts(componentType, artifactTypes) | 定義結果中預期的組件類型,以及要為此類型的組件檢索的 Artifact。目前,僅允許單一組件類型和 Artifact 集合。 |
withArtifacts(componentType, artifactTypes) | 定義結果中預期的組件類型,以及要為此類型的組件檢索的 Artifact。目前,僅允許單一組件類型和 Artifact 集合。 |
ArtifactResolutionResult
execute
()
實際執行查詢,並傳回查詢結果。請注意,在執行查詢之前,必須先呼叫 ArtifactResolutionQuery.withArtifacts(java.lang.Class, java.lang.Class[])
。
ArtifactResolutionQuery
forComponents
(Iterable
<? extends ComponentIdentifier
>
componentIds)
Iterable
<? extends ComponentIdentifier
>指定要包含在結果中的組件集合。
ArtifactResolutionQuery
forComponents
(ComponentIdentifier
...
componentIds)
ComponentIdentifier
...指定要包含在結果中的組件集合。
ArtifactResolutionQuery
forModule
(String
group, String
name, String
version)
使用其 GAV 座標指定要包含在結果中的模組組件。
ArtifactResolutionQuery
withArtifacts
(Class
<? extends Component
>
componentType, Class
<? extends Artifact
>...
artifactTypes)
Class
<? extends Component
>Class
<? extends Artifact
>...定義結果中預期的組件類型,以及要為此類型的組件檢索的 Artifact。目前,僅允許單一組件類型和 Artifact 集合。
ArtifactResolutionQuery
withArtifacts
(Class
<? extends Component
>
componentType, Collection
<Class
<? extends Artifact
>>
artifactTypes)
Class
<? extends Component
>Collection
<Class
<? extends Artifact
>>定義結果中預期的組件類型,以及要為此類型的組件檢索的 Artifact。目前,僅允許單一組件類型和 Artifact 集合。