This message was deleted.
# dependency-management
s
This message was deleted.
g
I don't understand why I'd need to declare repos in pluginManagement, since I'm using the dependency as a regular project dependency, not as an applied plugin
m
Maybe it's required to build your included build?
Wait, AGP is a regular dependency of
settings-plugin-included-build
, right?
But it's a plugin dependency of your main build I guess?
g
Yep Main build • includes build of settings plugin ◦ settings plugin has a regular dependency on AGP • applies settings plugin
m
the transitive dependencies of your settings plugin are seen as "plugin" dependencies from your main build
Not sure if that helps but I've gone a similar route of factoring in the repositories declaration in a composite build lately. I used a script that's applied in different builds and I'm happy with it
g
Neat trick! But I'm not sure how to make it work with a build that contributes a Settings plugin. With 1, I get the same "Could not resolve AGP" error, but I can't use 2 because it's a Settings plugin ("Plugin with id 'plugin' not found.")
m
This seems to work:
Copy code
pluginManagement {
  includeBuild("settings-plugin-included-build")
  apply(from = "./gradle/repositories2.gradle.kts")
}
repositories2.gradle.kts:
Copy code
listOf(pluginManagement.repositories, dependencyResolutionManagement.repositories).forEach {
  it.apply {
    mavenCentral()
    google()
    gradlePluginPortal {
      content {
        includeModule("org.gradle.kotlin.embedded-kotlin", "org.gradle.kotlin.embedded-kotlin.gradle.plugin")
        includeGroup("org.gradle.kotlin")
        includeModule("me.champeau.gradle", "japicmp-gradle-plugin")
        includeModule("com.gradle.publish", "plugin-publish-plugin")
        includeModule("com.github.ben-manes", "gradle-versions-plugin")
      }
    }
    @Suppress("DEPRECATION")
    jcenter {
      content {
        // <https://github.com/Kotlin/kotlinx-nodejs/issues/16>
        includeModule("org.jetbrains.kotlinx", "kotlinx-nodejs")
      }
    }
  }
}
Just apply from inside the
pluginManagement{}
block
g
That does work, thank you!
Note: it only works in Kotlin DSL for some reason. In Groovy, it complains that "pluginManagement only allowed in Settings scripts"
m
Ah, interesting!
Might be worth opening an issue