I want to programmatically pick a version from a V...
# gradle
d
I want to programmatically pick a version from a Version Catalog from within the
plugins
block, but it seems like Gradles API is juuuust about designed to make this impossible!? Is there some way that I'm missing? • A function to choose a string key for the version can be made available from
buildSrc
• The type-unsafe accessors needed to select a version by key, cannot be accessed from within
plugins {}
because a handle on
project
is not available. : •
libs
can be accessed through (apparently) some Gradle 'black magic' but,
libs
does not re-expose the type-unsafe accessor either from the generated
LibrariesForLibs
type or its
AbstractExternalDependencyFactory
supertype.
👀 1
v
The
plugins
block is very restrictive on what you can do: https://docs.gradle.org/current/userguide/userguide_single.html#sec:constrained_syntax So even if you would be able to access the stringy API, you would probably not be allowed to call it. If you really need such logic, write a custom plugin that has the logic and applies the respective plugin, then apply that plugin in your build script.