This message was deleted.
# community-support
s
This message was deleted.
m
The extension will only be present if there's a catalog. So my guess is that there's none.
r
it seems that the extension is not available yet in build scripts that apply my custom plugin in a setting like
Copy code
configure(subprojects - project('elasticsearch-log4j')) {
  /*
   * All subprojects are java projects using Elasticsearch's standard build
   * tools.
   */
  apply plugin: 'elasticsearch.build'
}
I know its not the best approach and I'm about to fix that, but thats how it is at the moment and the dynamics of how this extension is created does not work with this way of configure things
m
the
VersionCatalogsExtension
exposes a realized catalog
in settings you have access to the builder API
(settings plugins can contribute catalogs, or mutate existing catalogs, so the "realized" version is not yet ready)
r
I just want to consume an existing catalogue I have defined in my settings file
m
then it should be visible 🤔
r
that ugly workaround on defering acccessing version catalogue extension actually works:
Copy code
var checkstyleDependencyProvider = project.provider(
                () -> project.getExtensions().getByType(VersionCatalogsExtension.class).named("buildLibs").findLibrary("checkstyle").get().get()
        );
        dependencies.addProvider("checkstyle", checkstyleDependencyProvider);
🤮
m
this would imply your plugin is applied before the extension is added. I'm not sure how you managed to do that 😄
r
I'm a pro
😛
m
don't do this at home
can you defer the application of your plugin somehow?
r
maybe. I will try to reproduce that in a small example project first
I'd rather not do that defering 🙂
do you recall when and where that extension is added?
m
I recall it was complicated, and if I recall properly, it's once settings are evaluated
ah no, that's for the catalog creation, for the extension itself... I don't remember.
r
I have a closer look and try creating a reproducible example to raise a ticket 🙂
m
this should be quite early, because catalogs can be used in the plugins block
r
I think with my sample configuration snippet above of configuring subprojects this breaks that
v
Are you sure you tried to get it from the correct extensions? Most time I have seen that extension not be present was because someone just used unqlified
extensions
and thus tried to get it from a task, instead of from the project.
m
very good point
r
yeah that was one thought too but in my example its explicit. I'm just writing the bug report. and the minimum example snippet that shows the problem is:
Copy code
// this works!
def versionCatalogRoot = extensions.getByType(VersionCatalogsExtension).named("buildLibs")
println(versionCatalogRoot.findLibrary("checkstyle").get().get())

subprojects {
    // this throws "Extension of type 'VersionCatalogsExtension' does not exist."
    def versionCatalog = extensions.getByType(VersionCatalogsExtension).named("buildLibs")
    println(versionCatalog.findLibrary("checkstyle").get())
}
m
can you avoid the use of
subprojects
?
r
yeah thats what I will do I think to unblock me. Will create a ticket anyhow
m
subprojects/allprojects is always full of surprises... that said, I still have to find a replacement for when you use an init script which needs to interact with arbitrary projects
r
yeah I'm in the process of moving away from them but it takes time 🙂
m
no judgement here
r
just getting our codebase to configuration-cache compliant is a task for months (/ or years) :P
m
don't tell me about this. Micronaut is full of tricks which would probably explode with the CC.
r
yeah our integration test infrastructure for managing elasticsearch nodes in any possible way is full of garbage
magic
but you need goals to aim for...
m
gives you a job for years 😄
r
to close the loop... https://github.com/gradle/gradle/issues/21191 now I need to rewrite my build scripts in the mean time