Peter
04/22/2020, 7:10 PMval
but they don’t appear to be in scope for the buildscript
block right below, though work fine for allscripts
or subprojects
eg:
val artifactVersion: String by project
buildscript {
version = artifactVersion // unresolved reference
}
allprojects {
version = artifactVersion // ok
}
seeing as these constants are dependent on project
it’s not clear how I can move this to buildSrc
and make them available everywhere.
if i redeclare them with the buildscript
block it works but that defeats the purpose (i have many of these constants)octylFractal
04/22/2020, 7:16 PMbuildscript {}
block is special and executed prior to everything outside of it, so you can't use variables from outside of the block inside it because they're not executed yet. the plugins {}
block is similar.octylFractal
04/22/2020, 7:19 PMbuildSrc
if there's a need to share versions between buildscript
and allprojects
-- but usually there's not too many things that should be in both blocks, as they serve very different purposesoctylFractal
04/22/2020, 7:20 PMdependencies {}
blockoctylFractal
04/22/2020, 7:21 PMbuildSrc
https://github.com/EngineHub/WorldEdit/blob/master/buildSrc/build.gradle.kts#L40-L46Peter
04/22/2020, 7:29 PMversion
was just an example, i’m actually grabbing credentials from project properties with a fallback to env variables and then creating multiple MavenArtifactRepository.() -> Unit
that i can use in the `buildscript`/`allprojects` and subprojects
blocks