Paul Verest
Paul Verest

Reputation: 64031

Make Gradle use Maven local repository for downloading artifacts

I know I can configure Gradle to use local Maven repository

repositories {
    mavenLocal()
    mavenCentral()
}

Can I configure Gradle to download into Local (maven) repository? (So that Maven would also be able to use those jars)

ref Gradle configuration to use maven local repository

Upvotes: 9

Views: 3889

Answers (2)

tkruse
tkruse

Reputation: 10695

A solution was given in the gradle forums: https://discuss.gradle.org/t/need-a-gradle-task-to-copy-all-dependencies-to-a-local-maven-repo/13397/2

using this gradle plugin: https://github.com/ysb33r/ivypot-gradle-plugin you can call a new tasg

gradle syncRemoteRepositories

which will download all dependencies to a local Ivy repository (which is the same library Maven uses). The folder you point to with

syncRemoteRepositories {
   repoRoot '/path/to/repo'
}

will contain the dependencies. I would suggest first trying out with a different local path than your M2_HOME, because I saw some warning about the Ivy repository structure having changed between Maven versions.

Upvotes: 3

lance-java
lance-java

Reputation: 28099

It should be as simple as

apply plugin: 'maven'
apply plugin: 'java'
dependencies {
    mavenLocal()
}        

And

gradle install

More info here

Upvotes: 0

Related Questions