Is it possible to use version catalogue in the scr...
# scripting
e
Is it possible to use version catalogue in the scripts?
h
Funny, I just created a Gradle task a few minutes ago that writes the gav from the version catalog. I guess, you could include these strings in your DependsOn easily 🤔
i
If you mean
@DependsOn
annotation as it used in the
main-kts
then - no, unfortunately you cannot use it there.
h
You can’t use strings defined in another file? 🤔
i
As an annotation parameter - no.
e
That should be java constants - if you can generate file and compile it and add it class path - then probably you can do it
And I understand now why I can not use version catalogue in scripts directly
h
I don’t get it. The DependsOn annotation is extracted and parsed by its own to get the classpath without any references to other files (thanks to Ilya), so you can’t reference a String constant defined in another file. But if you already have control of the classpath used by the scripting host because you set up the environment and the context by ourself, it should be possible to reuse dependency catalogs and set the classpath directly, shouldn’t it?
i
Of course, from the script definition/host you can set the classpath freely using any source. So if you want to add a support for version catalogs, you can adapt the appropriate callback code (e.g. starting from
main-kts
definition) and add it there. It should be relatively easy. I'm just saying that you cannot use it out of the box in a
.main.kts
script.