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
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
Hi AndyLau,
you should read the code blocks as “closures” 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
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 - 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#resources(groovy.lang.Closure)
–>
https://docs.gradle.org/2.8/javadoc/org/gradle/api/file/SourceDirectorySet.html#srcDir(java.lang.Object)
HTH,
Marian
Thanks for reply!
i am curious that in " sourceSets { } ", is this a method call with name “sourceSets” and a closure arg ?