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?
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.
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.
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.
xml Follow. Gradle uses Maven's settings. xml.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With