Build.gradle groovy technicals

good afternoon

if I have e.g. java plugin applied in my build.gradle and then later in the code I have

test {
// just example
enabled = false
outDir = …

what exactly is it related to groovy language? and how does the configuration gets applied? I suppose this test {} block relates to test task from java plugin, and it get’s somehow parsed, then applied to the code of test task… where in gradle source code can I find exactly, how this is being implemented?

thx a lot


The official apidoc of Project mentions dynamic methods:

Dynamic Methods
A project has 5 method ‘scopes’, which it searches for methods:

  • […]
  • The tasks of the project. A method is added for each task, using the name of the task as the method name and taking a single closure or Action parameter. The method calls the Task.configure(groovy.lang.Closure) method for the associated task with the provided closure. For example, if the project has a task called compile , then a method is added with the following signature: void compile(Closure configureClosure) .

I could not find the exact location in the Gradle source code, but I assume that the binding to the configure method is done with some Groovy metaprogramming probably by adding some method on the project’s meta class.