简体   繁体   中英

How to declare repository details outside build.gradle

I am using repositories{} block to declare repositories for dependency resolution in build.gradle file. Is there any way to declare repositories outside build.gradle file so that I don't have to declare for every other projects.

I am coming from maven background where we could declare repositories in settings.xml in .m2 folder.

Please advice.

The source of your dependencies are an important part of your build. It is one of the many elements that help provide reproducible builds. Maven assumes that a given version of a dependency is the same in all repositories. Sadly, this is not true.

So it is natural to declare repositories in each Gradle build. This can be externalized by having the declarations come from an external script which is applied in your project.

And that script should rely on the allprojects block to make sure repositories are added to all the projects of a multi project build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM