Can I react to a configuration being registered ? ...
# community-support
m
Can I react to a configuration being registered ? (Not configured)
v
For what reason?
Generally, the configuration container is a
NamedDomainObjectContainer
like any other
So you could e. g. do
_configurations_.whenObjectAdded
but iirc that completely disables laziness as then all need to be realized to trigger that hook.
😢 1
e
https://github.com/gradle/gradle/issues/25262 is a feature request for
TaskContainer
, I think your request is the same but for configurations
v
Should probably be
whenObjectRegistered
and on NDOC, then also the task container should have it.
e
basically the
whenElementKnown
method. but it's not public
v
Yeah, same work-around as in that ticket could work, something like
Copy code
(configurations as org.gradle.api.internal.DefaultNamedDomainObjectCollection<Configuration>).whenElementKnown { ... }
👀 1
So still the question, what is the use-case, maybe there is a better way someone can come up with.
m
It's here
Copy code
project.pluginManager.withPlugin("java") {
      onApi("apiElements")
      onRuntime("runtimeElements")
    }
etc...
I'm playing cat and mouse with each plugin to know when they register their outgoing configurations
I could probably investigate each plugin and try to understand when those are created and use proper APIs for that but it's a huge pain
e
@tony did you mean to reply to the #CRA9GTYBH thread? doesn't seem particularly relevant to this one
t
oh lol, thanks edit: deleted other, irrelevant, message