Anybody using RepositoryHandler extension function...
# gradle
a
Anybody using RepositoryHandler extension functions like this in their settings.gradle.kts file? i can use this extension to clean up my dependencyResolutionManagement block but it does not work when used inside pluginManagement block. i always get unresolved reference errors. any ideas? (it does not matter where i put the extension functions in the file top or bottom)
v
The
pluginManagement
is special like some other blocks. It is extracted and evaluated separately to find out where to resolve plugins (including settings plugins from). Without that knowledge the settings script cannot be compiled as Gradle cannot know where to take the settings plugins from. But because of that you can of course not access anything outside that block from within.
But this is not true for the opposite. You could configure the
dependencyResolutionManagement
block from inside the
pluginManagement
block. While not being super clean, you could then use the same extension function for both.
a
The thing is I can’t even pass lambdas to it that are then applied in the repositories block. Really weird
v
How should that be weird? I just explained it to you.
It is extracted before the script is compiled and evaluated separately. It cannot access anything outside. Your lambda is outside.
And it is not even compiled yet.
a
@André Thiele you can extract this configuration into the gradle settings plugin into build-logic and apply it from the root settings.gradle.kts. This is how I usually do it: repositories.settings.gradle.kts
v
That will not help for settings plugins though! Doing it like that is too late for resolving settings plugins from those repositories.
a
Yes, that's true. But for building Gradle Settings Plugins we usually don't need any plugins specifically from the Google repository and it's not added here. Of course, some other repositories may require special handling