# Methods in extensions -\> custom plugin

**URL:** <https://discuss.gradle.org/t/methods-in-extensions-custom-plugin/4617>\
**Category:** Old Forum Archive\
**Created:** [January 15, 2013, 1:27pm UTC](https://discuss.gradle.org/t/methods-in-extensions-custom-plugin/4617 "2013-01-15T13:27:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zbyszek\_Sokolowski](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zbyszek_sokolowski/32/384_2.png) [@Zbyszek\_Sokolowski](https://discuss.gradle.org/u/Zbyszek_Sokolowski)\
**Post date:** [January 15, 2013, 1:27pm UTC](https://discuss.gradle.org/t/methods-in-extensions-custom-plugin/4617/1 "2013-01-15T13:27:00Z")

</div>

How can I use method in extension in custom plugin, I would like to have the same functionality as in sonar plugin:

```gradle
void withProjectProperties(Closure block) {
        propertyProcessors << block
    }

```

I was trying something like this but it doesn’t work:

```gradle
Map <String, String> sonarProps = project.sonarutils.cpp.sonarProperties
    for (Map.Entry<String, String>
entry:
sonarProps)
{
      project.sonar.project.withProjectProperties { props ->
        props[entry.key] = entry.value
      }
    }

```

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [January 15, 2013, 3:19pm UTC](https://discuss.gradle.org/t/methods-in-extensions-custom-plugin/4617/2 "2013-01-15T15:19:00Z")

</div>

There is nothing special about it - you just grab the extension object, and call the method. There must be something else wrong with your code.

---

<div class="post-metadata">

**Author:** ![Zbyszek\_Sokolowski](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zbyszek_sokolowski/32/384_2.png) [@Zbyszek\_Sokolowski](https://discuss.gradle.org/u/Zbyszek_Sokolowski)\
**Post date:** [January 16, 2013, 9:56am UTC](https://discuss.gradle.org/t/methods-in-extensions-custom-plugin/4617/3 "2013-01-16T09:56:00Z")

</div>

please do better examples on extensions, but it worked with your tip
