Need information for changing a syntax of compile closure in build.gradle

HI,
I had a syntax for excluding transitive dependencies in compile closure. I surfed the gradel DSL reference for exclude method in compile closure.
https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/ModuleDependency.html
The exclude method takes Map<String,String> as argument and exclude them from classpath.
But I have some questions?

  1. When the exclude() method executed?
  2. How can i added new syntax to the closure of compile method.

I need some reference of it, I want to contribute this kind of syntax.

             compile ('group-name:module-name:version')
             {
                 exclude group:'group-name' // this is the current syntax
                 exclude group:'group-name'
             }

The syntax I wanted to include

     compile ('group-name:module-name:version')
     {
       exclude group:[ 'group-name1', 'group-name2' , 'group-name3', ...] // this is what i want to add
     }

Just use groovy goodness:

compile('group-name:module-name:version') {
    ['group-name1', 'group-name2', 'group-name3', ...].each {
        exclude group: it
    } 
}

thank u for the answer, I like groovy :blush: