How to get configuration names?

configurations {
or in other words and more general:
How to get property names from a closure in Groovy script … I suppose using reflection?
What is the code of “Hackery of short-circuiting the expensive property and method look up”?

You cannot get “names from a closure”, that is not a thing.
The Gradle Groovy magic of just writing the names there dynamically creates configurations with these names.
You can get all configuration names using configurations.names, but you will get the names of all currently existing configurations, not only the ones you created yourself, but also all that were created by some plugins.

Thank you.
I understand concepts of configurations and their project container.
I was rather curious of the groovy magic that pulls out declared properties from the closure.

Ah, I see, sorry I misunderstood your question.
In Groovy there are multiple ways to do this.
You can for example have a propertyMissing method or a custom meta class that handle missing properties being accessed and then act upon that fact.

1 Like