Reputation: 6195
I'm going through some simple Gradle examples, and trying to get my head around the syntax. According to Gradle syntax, there must be a method called 'main' somewhere on 'sourceSets' (which is a SourceSetContainer) that takes a Closure. I figured that I would be able to find it by browsing around the Gradle javadocs, but I can't find it. Can someone point me to where 'main' is defined in this example?
apply plugin: 'java'
sourceSets {
main {
java {
srcDirs = ['src']
}
}
}
Upvotes: 0
Views: 745
Reputation: 123950
sourceSets
is a container of named source sets. The java
plugin adds a source set named main
(and another named test
) to that container. As such, there is no physical method or property called main
. sourceSets.main { ... }
could also be written as sourceSets.getByName("main") { ... }
.
Upvotes: 3