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:

/dep1-1.0.jar
/dep2-1.0.aar
...

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.

Answers


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) {
            from components.java
        }
    }
    repositories {
        maven {
            url "/path/to/wherever"
        }
    }
}

See the Maven Publish plugin docs


Need Your Help