How to specify a single repo for ALL dependencies

Our gradle build (version 7.4.2) runs on an isolated network that has no access to the Internet. It can only access our self-hosted maven mirror (an artifactory instance). So I want to ensure that all gradle dependencies (plugins + normal dependencies) can only be fetched from that one repo.

I thought this would suffice in our root settings.gradle.kts:

pluginManagement {
    repositories {
        maven {
            url = uri("https://myartifactory.jfrog.io")
            credentials {
                username = System.getenv("ARTIFACTORY_API_USERNAME") ?: ""
                password = System.getenv("ARTIFACTORY_API_KEY")
            }
        }
    }
    includeBuild("gradle/plugins")
}

dependencyResolutionManagement {
    repositories {
        maven {
            url = uri("https://myartifactory.jfrog.io")
            credentials {
                username = System.getenv("ARTIFACTORY_API_USERNAME") ?: ""
                password = System.getenv("ARTIFACTORY_API_KEY")
            }
        }
    }
}

I tested this on my local machine and it seemed to work, but it fails on our build machine because it turns out it’s still trying to use the Gradle Central Plugin repository and in fact cannot resolve the kotlin-dsl plugin from artifactory:

- Plugin Repositories (could not resolve plugin artifact 'org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:2.1.7')
  Searched in the following repositories:
    Gradle Central Plugin

Which I find weird for two reasons:

  1. Why is Gradle Central Plugin listed there? How do I remove that as an option?
  2. Why is my desired repository not listed as being searched?

For example I can browse my artifactory and see that it has an artifact at https://myartifactory.jfrog.io/org/gradle/kotlin/kotlin-dsl/org.gradle.kotlin.kotlin-dsl.gradle.plugin/2.1.7/. I don’t understand why gradle can’t resolve that.

I figured it out. Because gradle/plugins is a separate gradle build, that pluginManagement block does not apply to it. I need to repeat that pluginManagement declaration in gradle/plugins/settings.gradle.kts