https://kotlinlang.org logo
Title
d

Dariusz Kuc

01/10/2020, 9:55 PM
hello, is there a way to share common properties between composite builds? e.g. given
rootA
- build.gradle.kts
- gradle.properties <-- share this
- settings.gradle.kts
- libA
- libB
- pluginA
- rootB
  - build.gradle.kts
  - settings.gradle.kts
  - exampleA (uses libA/libB and pluginA)
Is there a way to share
rootA/gradle.properties
with
rootB
project?
in
rootA
I'm loading those props to set common version of plugins, e.g.
//settings.gradle.kts
pluginManagement {
  val someLibVersion: String by settings
  plugins {
    id("whatever) version someLibVersion
  }
}
so basically would like to define common version of some libs and properties that should be used by both
rootA
and
rootB
project
o

octylFractal

01/10/2020, 9:58 PM
I don't see anything immediately, but you could technically read them from the relevant properties file yourself, by using https://docs.gradle.org/current/dsl/org.gradle.api.initialization.IncludedBuild.html#org.gradle.api.initialization.IncludedBuild:projectDir to locate the file
d

Dariusz Kuc

01/10/2020, 10:00 PM
well probably will just end up copying the properties over
oh well
d

dwursteisen

01/11/2020, 10:53 PM
Depending of what you want to achieve but starting gradle 5.6 or something, you can put a gradle.properties in a custom gradle distribution that will be used In (all) projects using this gradle distribution.
d

Dariusz Kuc

01/11/2020, 11:58 PM
That would be an overkill
so i tried this in
rootB/settings.gradle.kts
pluginManagement {
    val properties = java.util.Properties()
    properties.load(File(rootDir.parent, "gradle.properties").inputStream())

    val kotlinVersion: String by properties

    plugins {
        id("org.jetbrains.kotlin.jvm") version kotlinVersion
    }
}
and it appears to work fine from command line but intellij complains 😞
hmm so actually IntelliJ complains about the
plugins
section
🤦 intellij was trying to use old version of gradle... above works fine