Exclude certain paths from repositories


(Kushal Kadaba) #1

Hi,
I have a long and winding question for something that might have a very simple answer. Please bear with me.
I recently ran into an issue with my android project where the project was not able to find ‘android.arch.lifecycle:runtime:1.0.3’. It looks like this was due to this https://docs.gradle.org/4.3/release-notes.html#avoid-checking-other-repositories-when-dependency-resolution-in-one-repository-fails . My project had both jcenter() and google() listed in repositories. So gradle looked for the runtime dependency in jcenter (since that was declared first). It found some metadata in https://jcenter.bintray.com/android/arch/lifecycle/runtime/maven-metadata.xml so it assumed that the aar also would be available there, but it wasn’t and broke the build. Now I solved my issue by rearranging the repositories, but it is not hard to imagine a situation, especially with immutable public repositories like jcenter, where there could be 2 dependencies (say dep1 & dep2) whose metadata is listed in both repositories (say A and B), but only A has dep1 and B has dep2.
In that case is there a way to specify that gradle shouldn’t look for dep1 in B?