I have a bit of an unusual need. In my `build.gra...
# community-support
j
I have a bit of an unusual need. In my
build.gradle.kts
file I want to add an enterprise plugin which is located in our internal repositories.
Copy code
plugins {
  id("my.enterprise.plugin") version "1.0.0"
}
In order to do that I need to add the repository in
pluginManagement.repositories
. But the issue here is that in order to add that repository I need to use a plugin:
Copy code
pluginManagement {
  plugins {
    id("sh.tnn") version "0.3.3"
  }
  repositories {
    github.use("myenterprise", "plugin") // github.use is added by sh.tnn
  }
}
The problem is that the
github
extension is not found (it is definitely registered as an extension), but I fear that Kotlin / Gradle does not detect it early enough. Any tips?
e
pluginManagement
is evaluated before any plugins are applied, and I don't think that will ever change as it's a chicken-and-egg problem
j
Hmm.. How should I go on about this? Is there no way to get a plugin to load before
pluginManagement
?
e
no there isn't. for this particular case you will have to configure the plugin repositories directly
j
That's sad 😞
Is there a way to configure repositories globally?
e
there's pluginManagement.repositories and dependencyResolutionManagement.repositories, which together should cover most use cases within a build
e
You could use an init script.
They are useful for various purposes:
• Setting up enterprise-wide configurations (e.g., custom plugin locations)
• ...
https://docs.gradle.org/current/userguide/init_scripts.html
🎉 1
Sorry. I just re-read your use case and now I'm not sure. I thought you were asking how to resolve a settings plugin from an internal repository without explicitly needing to define the repository in the script.