Generate local maven repository with all dependencies using Gradle

What I currently have
dependencies {
    compile ...

task copyDependencies(type:Copy) {
    from configurations.compile
    into 'build/dependencies/'

This task copies all the required dependencies to the build/dependencies/ directory. Inside the directory, it looks as follows:


So essentially what is known as flatDir in gradle terms.

What I'd like to have

It's a local maven repository with all these dependencies, instead of a flatDir.


If I understand your question correctly, you just want to publish to a local directory as if it were mavenLocal() but in a location you specify.

In that case, I believe you just need:

apply plugin: 'maven-publish'

publishing {
    publications {
        mavenJava(MavenPublication) {
    repositories {
        maven {
            url "/path/to/wherever"

See the Maven Publish plugin docs

Need Your Help