The gradle-versions-plugin tries to aggregate all repositories before searching for dependency updates. This was done because originally it used a detached configuration to perform the resolution where the dependency version was set to a latest query. The current version modifies a copy of the original configuration, so this aggregation is no longer necessary.
It turns out the aggregation is error prone due to RepositoryHandler determining uniqueness based on the repository’s name. If duplicate repositories are added without an explicit name then both are listed and redundant queries are issued. If different repositories are added with conflicting names, e.g. maven { name = ... url = ... }, then only the first is added. Repositories themselves do not have an equality definition.
It appears that there are 3 options,
Perform no aggregation and resolve each configuration using the repositories associated with it. This has the benefit of not using unnecessary repositories (e.g. plugin repository for compile scoped dependencies) with the cavet of a smaller scanning radius.
Attempt to infer equality by inspecting the repository’s configuration (may be error prone)
$ gradle
Add to existing set
maven: https://repo1.maven.org/maven2/
Clear and add
maven: https://repo1.maven.org/maven2/
maven: https://jcenter.bintray.com/
It turns out that add and addAll result in different behavior.
We could easily solve this, if Gradle offered a way to check repository instances for equality (ignoring the name property of course). We could do that in the plugin manually, but I think the right place to do that would be inside Gradle itself. A plugin should not need to know that for example mavenCentral() and maven { url 'https://repo1.maven.org/maven2/'} are equal.