Is there a way to figure out what all public repos...
# dependency-management
r
Is there a way to figure out what all public repository for dep resolution are added in the project, apart from looking at where a particular dependency is getting pulled from.
A way to see - if something like
mavenCentral()
is getting added somewhere in the chain, even though the project didn't declare it explicitly.
v
Ah easy way to prevent that is, to declare the repositories centrally in the settings script and switch the mode to fail on project repos. If then some project tries to add one or a bad practice plugin tries to add one, build will fail. Unless of course it is a settings plugin that adds the repository, but I think this is quite unlikely. But other than that, you can just iterate over the repositories to check what is added right now.
1
r
Yea, we have
Copy code
dependencyResolutionManagement {
  @Suppress("UnstableApiUsage")
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  ......
}
which prevents and should theoretically. We point or pull deps from our own artifactory, where the deps are mirrored. Started to notice 429, streaming from public maven for few coordinates.
Hence, the question - if the fetch from our artifactory fails can gradle build point to public maven or in any other scenario. Nothing stands out from the project itself though.
v
With that setting neither projects nor project plugins can add any repositories without failing the build (unless that is broken which I don't believe). Do you also point the plugin repositories to your artifactory? Which coordinates are affected, is something outstanding for them? Without further investigation, the only thing that comes to mind would be a settings plugin that adds the repository. But just iterate over the repositories or set a breakpoint and check in the debugger.
r
Yes for plugins as well.
Copy code
pluginManagement {
  repositories {
    maven(url = "https://...")
  }
}
Yep, looking at iterating it and see if something stands out. > Which coordinates are affected Noticed few pointing at - https://repo.maven.apache.org/maven2/com/github/ajalt/mordant/mordant/3.0.2/mordant-3.0.2.pom which should be fetched from our own proxy.
I am looking, but was wondering if projects dep-resolution block also need
Copy code
rulesMode.set(RulesMode.FAIL_ON_PROJECT_RULES)
🤔
v
What is
rulesMode
?
Or did you mistype rules for repository
If so, then no, that is not even a thing, and would be quite strange anyway, because if you declare in the settings script that projects must not have own repositories and then projects can ignore that, it would be quite useless. 😄
👍 1
r
Sorry..
Copy code
dependencyResolutionManagement {
  @Suppress("UnstableApiUsage")
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)

  rulesMode.set(RulesMode.FAIL_ON_PROJECT_RULES)
}
v
Ah, forgot about that, but no, I don't thinks so. That setting is about component metadata rules which you can like repositories either declare in the settings script or in the project build scripts but not both. And just like the repositories you can then forbid either or configure which should be preferred. But that should not have anything to do with the repositories.
r
Ahh thanks.
👌 1