This message was deleted.
# community-support
s
This message was deleted.
v
That is not really that new. That API existed since the beginning, there was just no type-safe accessor for the
versionCatalogs
extension which is the new thing mentioned there. You can still not use type-safe accessors without my hack-around, but only that string-y API you could also use before.
c
I thought this was part of your thing?
val libs = the<LibrariesForLibs>()
I'm just trying to figure out if I should be be changing these 2 patterns in my repo I guess
v
No, that's a completely different thing.
What is described there is just a fix for https://github.com/gradle/gradle/issues/22468
c
lol, then where did I get this stuff for static accesors in buildSrc (I don't remember why I did these), although I know the latter fixes accessors
well... ok, your thing is different... so I should keep on, keeping on with what I'm doing given the code I pasted?
v
Which cause the
versionCatalogs
extension of type
VersionCatalogsExtension
not being usable in precompiled script plugins, or at least not in ones used by others I'm not fully sure about the one or the other. Whether you want to use my hack-around and the typesafe accessors, or that officially supported string-y API is up to you. The precondition for using either solution is exactly the same, which is that the build you apply the plugin to has the expected entries in it version catalog.
c
wait, was this part of it? lol sorry, ongoing meetings...
Copy code
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
v
That's an essential part of my hack-around, yes
Probably the hackiest thing about it
c
I should document your, I mean, my code better 😉
like why did I do this, that way I can know if it needs to go away. I never feel like I really understand gradle 😕
and I'm pretty close to our expert
is this stuff needed for accessors in groovy?
v
No Groovy with its duck-typing does not need accessors. My hack-around is only needed for using the generated accessors in Kotlin DSL precompiled script plugins. In Groovy it just works, again with the same precondition that the expected entries are in the version catalog or the project you apply the plugin to.
c
does the rest of your workaround fix being able to use static accessors in
plugin {}
?
v
No, you cannot use the version catalog accessors in
plugin { ... }
blocks of precompiled script plugins even with my hack-around. This is not technically possible as the
plugin { ... }
block is extracted and applied to a dummy project to find out which static accessors for exensions and so on need to be generated. And on this dummy project my hack-around does not apply and cannot be made so.