# How to get configuration names?

**URL:** <https://discuss.gradle.org/t/how-to-get-configuration-names/44852>\
**Category:** Help/Discuss\
**Created:** [February 10, 2023, 9:16am UTC](https://discuss.gradle.org/t/how-to-get-configuration-names/44852 "2023-02-10T09:16:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Talavera316](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Talavera316](https://discuss.gradle.org/u/Talavera316)\
**Post date:** [February 10, 2023, 9:16am UTC](https://discuss.gradle.org/t/how-to-get-configuration-names/44852/1 "2023-02-10T09:16:36Z")

</div>

configurations {  
confA1  
confA2  
confB1  
confC3  
}  
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”?

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [February 10, 2023, 10:44am UTC](https://discuss.gradle.org/t/how-to-get-configuration-names/44852/2 "2023-02-10T10:44:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Talavera316](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Talavera316](https://discuss.gradle.org/u/Talavera316)\
**Post date:** [February 10, 2023, 2:20pm UTC](https://discuss.gradle.org/t/how-to-get-configuration-names/44852/3 "2023-02-10T14:20:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [February 10, 2023, 3:01pm UTC](https://discuss.gradle.org/t/how-to-get-configuration-names/44852/4 "2023-02-10T15:01:38Z")

</div>

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.
