I would like to use Gradle to download dependencies and their source files and place them all in one directory. I found this answer below that tells me how to do it for the dependencies themselves, but I would like to also get the source files. How do I do that?
I know that the Eclipse plugin can grab source files, but I don't know where it places them.
How can I use Gradle to just download JARs?
apply plugin: 'java'
configurations {
    runtimeSources
}
dependencies {
    compile 'foo:bar:1.0'
    runtime 'foo:baz:1.0'
    configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { ResolvedArtifact ra ->
        ModuleVersionIdentifier id = ra.moduleVersion.id
        runtimeSources "${id.group}:${id.name}:${id.version}:sources"
    }
}
task download(type: Copy) {
    from configurations.runtime
    from configurations.runtimeSources
    into "${buildDir}/download"
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With