This message was deleted.
# dependency-management
s
This message was deleted.
t
I think you'd have to use
gradle.beforeProject { buildscript.configurations.classpath { resolutionStrategy { … } }
or something like that.
👀 1
t
Nope, Gradle is failing with
Cannot change resolution strategy of dependency configuration 'classpath' after it has been resolved
t
🤔 already resolved in
beforeProject
, I'm almost certain I've changed
buildscript.repositories
that way and correctly seen the new URLs being used to download the dependencies in debug logs. Could it be that the
buildscript
wasn't targeting the ones from the project?
Fwiw, I couldn't reproduce that error. I could even add a dependency to the classpath configuration that way, and see it resolved correctly (put a broken one, and saw it fail)
Copy code
gradle.beforeProject { buildscript.dependencies.add("classpath", "foo:bar:baz") }
failing with
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'redacted'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find foo:bar:baz.
     Searched in the following locations:
       - <https://repo.maven.apache.org/maven2/foo/bar/baz/bar-baz.pom>
       - <https://plugins.gradle.org/m2/foo/bar/baz/bar-baz.pom>
     Required by:
         project :
t
I've tried to use following and it throws error:
Copy code
gradle.beforeProject {
    buildscript.configurations.all {
        resolutionStrategy.eachDependency {
            if (requested.group == "com.google.code.gson" && requested.name == "gson") {
                useVersion(versionProperties["versions.gson"] as String)
                because("Force using same gson version because of <https://github.com/google/gson/pull/1991>")
            }
        }
    }
}