Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 622
Paul Verest Avatar asked Jan 23 '17 10:01

Paul Verest


People also ask

Does gradle use Maven local repository?

Gradle can consume dependencies available in the local Maven repository. Declaring this repository is beneficial for teams that publish to the local Maven repository with one project and consume the artifacts by Gradle in another project.


1 Answers

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.

like image 122
tkruse Avatar answered Oct 05 '22 05:10

tkruse