Closed stefanleh closed 5 years ago
This can be done via an ArtifactResolutionQuery
apply plugin: 'java'
repositories { ... }
dependencies {
compile 'foo:bar:1.0'
runtime 'foo:baz:1.0'
}
task download {
inputs.files configurations.runtime
outputs.dir "${buildDir}/download"
doLast {
def componentIds =
configurations.runtime.incoming.resolutionResult.allDependencies.collect {
it.selected.id }
ArtifactResolutionResult result =
dependencies.createArtifactResolutionQuery()
.forComponents(componentIds)
.withArtifacts(JvmLibrary, SourcesArtifact)
.execute()
def sourceArtifacts = []
result.resolvedComponents.each { ComponentArtifactsResult component
->
Set<ArtifactResult> sources =
component.getArtifacts(SourcesArtifact)
println "Found ${sources.size()} sources for ${component.id}"
sources.each { ArtifactResult ar ->
if (ar instanceof ResolvedArtifactResult) {
sourceArtifacts << ar.file
}
}
}
copy {
from configurations.runtime
from sourceArtifacts
into "${buildDir}/download"
}
}
}
Great news! I will build the feature in the coming days based on this information.
Great, to get sources and javadoc you'll need to tweak
.withArtifacts(JvmLibrary, SourcesArtifact)
To
.withArtifacts(JvmLibrary, SourcesArtifact, JavadocArtifact)
On Mon, 25 Feb 2019, 8:32 am Stefan, notifications@github.com wrote:
Great news! I will build the feature in the coming days based on this information.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/uklance/gradle-dependency-export/issues/6#issuecomment-466916946, or mute the thread https://github.com/notifications/unsubscribe-auth/ABW1JC1PigZ4b6cKVNSG6HqkAF3-EIEDks5vQ5-vgaJpZM4bPR1b .
Sounds good. Will introduce switched for 'withSources' and 'withJavaDoc' then.
Perhaps two flags on the task
boolean exportSources boolean exportJavadoc
On Mon, 25 Feb 2019, 9:53 am Stefan, notifications@github.com wrote:
Sounds good. Will introduce switched for 'withSources' and 'withJavaDoc' then.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/uklance/gradle-dependency-export/issues/6#issuecomment-466947320, or mute the thread https://github.com/notifications/unsubscribe-auth/ABW1JNf-MsJs9lnAb9ASvpq7_meJrT5Lks5vQ7KGgaJpZM4bPR1b .
Id like to see sources packages for the resolved dependencies included via configuration switch. This would help if the file based repository the plugin creates get directly used by buildship. Buildship fetches the source packages for the defined dependencies by default but for this they need to be in the repository.