Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the gradle equivalent of maven repository mirrors?

Tags:

maven

gradle

When working with Maven projects, I like to configure a local mirror (e.g. Artifactory) for various 3rd party repositories. I do this via the settings.xml file in my home directory.

I cannot find a similar setting for Gradle - all documentation seems to suggest adding a new repository, rather than proxying/mirroring calls to repos which are already defined. This does not have the same effect. Is there a simple way to proxy remote Maven or Ivy repositories in Gradle?

like image 397
Armand Avatar asked Sep 23 '14 14:09

Armand


People also ask

Does gradle use Maven 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.

What is mirror repository in Maven?

You can force Maven to use a single repository by having it mirror all repository requests. The repository must contain all of the desired artifacts, or be able to proxy the requests to other repositories.

What is Maven Central in gradle?

Gradle has three "aliases" which we can use when we are adding Maven repositories to our build. These aliases are: The mavenCentral() alias means that dependencies are fetched from the central Maven 2 repository. The jcenter() alias means that dependencies are fetched from the Bintray's JCenter Maven repository.

Does gradle use Maven settings XML?

xml Follow. Gradle uses Maven's settings. xml.


1 Answers

You can define a custom repository such as:

// build.gradle or settings.gradle
repositories {
  maven {
    url "http://repo1.mycompany.com/maven2"
  }
  maven {
    url "http://repo2.mycompany.com/maven2"
  }
}

If you want to share this definition across projects, move it to an init script

like image 98
Amnon Avatar answered Oct 29 '22 17:10

Amnon