Methods in extensions -> custom plugin

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

void withProjectProperties(Closure block) {
        propertyProcessors << block

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

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

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.

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