Hey I was wondering if it was possible to have a custom version in the
plugins
section.
Copy code
val test_version: String by project
plugins {
id("random.plugin") version "$test_version"
}
I want to just have a single value to update that will update the version of a plugin in my entire project.
The current error being thrown is
'val test_version: String' can't be called in this context by implicit receiver. Use the explicit one if necessary
e
ephemient
09/17/2023, 4:52 PM
no, the
plugins
block (and a couple others, such as
buildscript
) are executed independently of the rest of the build script
ephemient
09/17/2023, 4:53 PM
those blocks affect the classpath so there's a chicken-and-egg problem otherwise
t
Tech
09/17/2023, 4:54 PM
Ah gotcha.
I'm running a monorepo setup so just being able to modify plugin versions like that would've been useful
e
ephemient
09/17/2023, 4:54 PM
why not use version catalogs? that is officially supported
t
Tech
09/17/2023, 4:54 PM
Oh never heard of that, I'll look into it
Tech
09/17/2023, 4:55 PM
Oh this looks much better, thank you
v
Vampire
09/17/2023, 7:06 PM
And before that was the
pluginManagement { plugins { ... } }
block which does exactly what you want too, defining a version that is used if a plugin is applied without version.
But yeah nowadays I'd also recommend version catalogs
t
Tech
09/17/2023, 7:07 PM
Yeah I've already implemented it with version catalogs, seems to be working fine.
Thank you everyone