Using library(String) extension from gradle/buildSrc/subprojects/configuration/src/main/kotlin/build-extensions.kt

(Ross Goldberg) #1

The build for the Gradle source uses the library(String) extension from gradle/buildSrc/subprojects/configuration/src/main/kotlin/build-extensions.kt.

Should I also use this extension to manage dependencies in my own Gradle project?

  • If so, how do I enable this extension? Calling library("a string") in my build.gradle.kts generates a compilation error, so, to use this, I must somehow import this functionality into my Gradle project
  • If not, what mechanism should I use to manage dependencies in my own Gradle project?

Once this works, if I have a dependency like the following:

dependencies {

What version does Gradle use? I imagine this depends on the versions specified for other dependencies in the same build on the same groupID & artifactID. If no other dependencies specify a version, does Gradle use the version returned from libraryVersion("guava")? If libraryVersion("guava") == "25.1-jre", and if some other dependency in the same build for the groupID & artifactID accepts anything newer than 20.0, what would Gradle use?

Is there any easy, non-verbose way to enable strict mode for all dependencies, so I don’t have to continually write the following (or make & use a helper function)?

library(name)) {
    version {