Slackbot
03/16/2022, 7:50 PMVampire
03/16/2022, 8:22 PMproject.buildscript?John Bellini
03/16/2022, 8:56 PMVampire
03/17/2022, 12:22 AMdependencies is where you declare them.John Bellini
03/17/2022, 5:26 PMregister("bbb") {
project.buildscript.configurations.forEach {
println("Bellini: configurations")
println(it.name)
println("Bellini: deps")
val deps = it.dependencies
// deps.iterator().forEach {
// println(it.name)
// }
it.allDependencies.iterator().forEach {
println(it.name)
}
}
}John Bellini
03/17/2022, 5:26 PMBellini: configurations
classpath
Bellini: depsVampire
03/17/2022, 5:31 PMdoLast)John Bellini
03/17/2022, 5:33 PMVampire
03/17/2022, 5:35 PMVampire
03/17/2022, 5:35 PMJohn Bellini
03/17/2022, 5:39 PMbuildSrc/build.gradle.kts looks like:
plugins {
`kotlin-dsl`
}
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
dependencies {
val versionKotlin = "1.5.10" // help with version upgrades to make sure all version are aligned in this file
implementation("org.jetbrains.kotlin:kotlin-allopen:$versionKotlin")
implementation("com.ea.stuff:stuff-common:16.6.0-SNAPSHOT") implementation("org.kie:kie-api:7.45.0.Final")
implementation("org.drools:drools-compiler:7.45.0.Final")
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.1")
}
What I want to programmatically obtain is the version of the dependency com.ea.stuff:stuff-common:16.6.0-SNAPSHOTVampire
03/17/2022, 5:43 PMVampire
03/17/2022, 5:44 PMplugins block and things from a buildscript { dependencies { ... } } block are buildscript dependenciesJohn Bellini
03/17/2022, 5:59 PMbuildSrc/build.gradle.kts dependencies which has the plugins listed + and code used in the build script?Vampire
03/17/2022, 6:11 PMbbb task?
And actually, what do you want to achieve?John Bellini
03/17/2022, 6:14 PMcom.ea.stuff:stuff-common:16.6.0-SNAPSHOT from the `buildSrc/build.gradle.kts`dependencies section.
The bbb task is in a stuff-conventions.gradle.kts file with in the buildSrc/src/main/kotlin/.../stuff-conventions.gradle.ktsVampire
03/17/2022, 6:15 PMbuildSrc and not an build.
plugins / dependencies from an included build end up on the buildscript class path.
(while you would still miss the dependency, because with your code you only get declared dependencies, no transitive ones which that one is from the viewpoint of the main build)
buildSrc dependencies are in its own class loader that is a parent of the build script class loader.
So those dependencies are not part of the build script configurations you are looking at.Vampire
03/17/2022, 6:16 PMJohn Bellini
03/17/2022, 6:17 PMVampire
03/17/2022, 6:19 PMWriteProperties task, or with a filter on processResources to fill in a blank in a properties file you create manually, that your convention plugin then can read at runtime.John Bellini
03/17/2022, 6:23 PMbuildsrc/build.gradle.kts can access it (haven't tried). Appreciate the ideas, I'll work through some of these and see what works.Vampire
03/17/2022, 9:54 PMtried adding it to gradle.properties and then reading the properties but the `buildsrc/build.gradle.kts`doesn't have access to that
buildSrc/gradle.properties I hope.
Otherwise it would make little sense.
Well, you could even read gradle.properties, but you then have to do it explicitly, using a Properties instance.