0

I read here that "the more repositories you add, the slower will be your build". Is that true ?

I thought that if the version of the artifact you have a dependency for is available in the .m2 folder, then the repositories won't even be queried, and if it isn't available, then maven will cycle through them just until it finds the correct artifact, and won't look any further. So in either case, it doesn't consume extra bandwidth.

n00begon
  • 3,503
  • 3
  • 29
  • 42
shkra19
  • 309
  • 2
  • 4
  • 13

2 Answers2

1

As indicated in this question there are some cases where Maven will search for a dependency in remote repositories even though it is already available in your local repository. This happens for SNAPSHOT dependencies or for dependencies missing the pom.xml. So what I can only assume the blog post might mean is that if your build falls under any of these categories Maven will scan the remote repositories you have defined in every build (actually for SNAPSHOTS you can restrict the repositories Maven will scan by enabling/disabling SNAPSHOTS from each repository as needed). If it can't find what it is looking for it will of course have to scan all the repositories before it gives up which means the more the repositories the more the time the scan will take (and in the case of SNAPSHOTS it will scan all the repositories anyway because event if it finds an updated version in one repository it can't "know" that another repository won't holder an even newer version). Even in the case where Maven actually finds the dependency it looks for and stops searching it is possible that the repository where the dependency is found is the last one scanned and so all other repositories are scanned before it.

Community
  • 1
  • 1
Christina
  • 3,562
  • 3
  • 22
  • 32
1

When you build your project it goes to the m2 repository for checking whether the jars are already present , if not it downloads the jar from the central repository . So if once the jars are downloaded , it doesnt take time when you build the project .

drusya
  • 288
  • 1
  • 2
  • 12