Skip to content

Instantly share code, notes, and snippets.

@dgroomes
Last active December 19, 2020 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgroomes/94f1032ec330ef7f1d9eaf6fa9dff597 to your computer and use it in GitHub Desktop.
Save dgroomes/94f1032ec330ef7f1d9eaf6fa9dff597 to your computer and use it in GitHub Desktop.
Download Maven dependencies using Gradle

Download Maven dependencies using Gradle

Download a Gradle project's Maven dependencies into a directory. For example, you might find this technique useful for very small and simple projects where you want to commit the .jar files directly into Git. This technique was taken from this StackOverflow answer.


Define a downloadDependencies Gradle task, that when executed, will put all of the project's dependencies into a directory named lib/.

task downloadDependencies(type: Copy) {
  from sourceSets.main.runtimeClasspath
  into 'lib/'
}

Gradle's Kotlin DSL

Alternatively, here is the same snippet but written using Gradle's Kotlin DSL (WARNING: I'm not sure if this correct):

tasks.register<Copy>("downloadDependencies") {
    val sourceSet = sourceSets.main.get().runtimeClasspath
    from(sourceSet)
    into("lib/")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment