Hi! I’m facing a strange behavior. It looks like d...
# dependency-management
e
Hi! I’m facing a strange behavior. It looks like declared repositories in
dependencyResolutionManagement
are not used in some circumstances. It happens only in included build in
pluginManagement
https://github.com/gradle/gradle/issues/20259
1
v
That's not strange but expected.
dependencyResolutionManagement.repositories
is for production dependencies, not for plugins and their dependencies. And besides that,
pluginManagement { ... }
is evaluated separately from the remaining script first, as it could for example add a settings plugin using
includeBuild
, that then can be applied outside the block. Define your repository in
pluginManagement.repositories
and it should probably work, as that is the place to define repositories for plugins and their dependencies.
e
pluginManagement.repositories
also has the same repositories:
Copy code
pluginManagement {
    repositories {
        gradlePluginPortal()
        mavenLocal()
        mavenCentral()
    }
}
It looks I found a reason. It’s a chicken and egg problem. Root project uses included build to modify his own repositories. Included build resolves dependency before this happens. Workaround to illustrate the issue:
Copy code
pluginManagement {
    repositories { // FIX is here: they are used to build build-logic-settings
        gradlePluginPortal()
        mavenLocal()
        mavenCentral()
    }
    includeBuild("build-logic-settings")
    includeBuild("build-logic")
}
// plugins from build-logic-settings modifies pluginManagement in this project 
plugins {
    id("convention-plugins")
    id("convention-dependencies")
    id("convention-enterprise")
    id("convention-cache")
}
v
Of course, as I said, the
pluginManagement
block is executed separately from the remaining script as it can for example contribute settings plugins to be applied in the same script.
e
Thanks for helping!
👌 1