Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use Gradle to download dependencies and their source files and place them all in one directory?

Tags:

java

gradle

jar

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?

like image 332
abrahamwl Avatar asked Oct 30 '25 03:10

abrahamwl


1 Answers

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"
}
like image 130
lance-java Avatar answered Oct 31 '25 17:10

lance-java



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!