# What is the syntax for this codes?

**URL:** <https://discuss.gradle.org/t/what-is-the-syntax-for-this-codes/13959>\
**Category:** Help/Discuss\
**Created:** [January 23, 2016, 8:23pm UTC](https://discuss.gradle.org/t/what-is-the-syntax-for-this-codes/13959 "2016-01-23T20:23:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![codepython](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@codepython](https://discuss.gradle.org/u/codepython)\
**Post date:** [January 23, 2016, 8:23pm UTC](https://discuss.gradle.org/t/what-is-the-syntax-for-this-codes/13959/1 "2016-01-23T20:23:47Z")

</div>

sourceSets{  
main{  
java{

```
srcDir 'src/main/java'

```

}

resources{  
srcDir ‘src/resources’  
}  
}

}

Is this in groovy syntax?  
Is here sourceSets a method call with a closure as its arg?  
And what is srcDir ‘src/main/java’ syntax meaning?

Thanks

---

<div class="post-metadata">

**Author:** ![marmax](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/marmax/32/2669_2.png) [@marmax](https://discuss.gradle.org/u/marmax)\
**Post date:** [January 25, 2016, 4:34pm UTC](https://discuss.gradle.org/t/what-is-the-syntax-for-this-codes/13959/2 "2016-01-25T16:34:57Z")

</div>

Hi AndyLau,

you should read the code blocks as [“closures”](http://www.groovy-lang.org/closures.html) which gradle will use to configure internal objects provided by various plugins.

So, read it as:  
There is a PROJECT object provided by gradle itself.  
Then, if you apply the java plugin, it enhances the PROJECT object with a collection of SourceSet (hence SourceSets) and adds MAIN (read default) SourceSet to it.  
Then you configure the MAIN SourceSet with SourceSetDir for “java” and “resources”

Appropriate documentation should be as follows:

[http://www.groovy-lang.org/closures.html](http://www.groovy-lang.org/closures.html)

[https://docs.gradle.org/2.8/dsl/org.gradle.api.Project.html](https://docs.gradle.org/2.8/dsl/org.gradle.api.Project.html) (look for “Properties added by the java plugin”)  
([https://docs.gradle.org/2.8/userguide/java\_plugin.html](https://docs.gradle.org/2.8/userguide/java_plugin.html) - see the chapter “23.2. Source sets”)  
–\>  
[https://docs.gradle.org/2.8/javadoc/org/gradle/api/tasks/SourceSet.html#java(groovy.lang.Closure)](https://docs.gradle.org/2.8/javadoc/org/gradle/api/tasks/SourceSet.html#java(groovy.lang.Closure))  
[https://docs.gradle.org/2.8/javadoc/org/gradle/api/tasks/SourceSet.html#resources(groovy.lang.Closure)](https://docs.gradle.org/2.8/javadoc/org/gradle/api/tasks/SourceSet.html#resources(groovy.lang.Closure))  
–\>  
[https://docs.gradle.org/2.8/javadoc/org/gradle/api/file/SourceDirectorySet.html#srcDir(java.lang.Object)](https://docs.gradle.org/2.8/javadoc/org/gradle/api/file/SourceDirectorySet.html#srcDir(java.lang.Object))

HTH,  
Marian

---

<div class="post-metadata">

**Author:** ![codepython](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@codepython](https://discuss.gradle.org/u/codepython)\
**Post date:** [January 31, 2016, 3:17am UTC](https://discuss.gradle.org/t/what-is-the-syntax-for-this-codes/13959/3 "2016-01-31T03:17:16Z")

</div>

Thanks for reply!

i am curious that in " sourceSets { } ", is this a method call with name “sourceSets” and a closure arg ?
