I’m deeply confused by Gradle’s highly abbreviated syntax. I’m used to programming languages like Python, Java, JavaScript, etc. where it is immediately obvious that
foo()
is a function call,
thing.foo()
is a method call,
foo = 42
is a variable assignment, etc.
But the relative lack of syntax in Gradle is strange and unfamiliar. For example, in
sourceSets {
common { ... }
app1 { ... }
app2 { ... }
}
… what is ‘sourceSets’? Am I calling a function? Using a language keyword? Assigning a variable? Setting an instance variable of some object?
Similarly, what are ‘common’, ‘app1’, and ‘app2’? Feel free to point me at the documentation that explains this, because I have clearly not found it myself. From the DSL reference, I think that I am creating three instances of org.gradle.api.tasks.SourceSet, but what are those user-specified names like ‘common’ – local variables? global variables? Instance variables of some hidden object that I cannot see?
It gets more confusing in the definition of one of those source sets:
common {
output.classesDir = file('classes/common')
java {
srcDirs = ['dir1', 'dir2', 'dir3']
exclude 'dir1/**/Test*'
exclude 'dir2/**/Mock*'
compileClasspath = files(['lib1.jar', 'lib2.jar'])
}
}
About the only thing I’m sure of here are the strings and lists of strings.
What is ‘java’ and what does it mean to follow it with what looks like a block of code? And why are some of those lines of code apparently variable assignments (“srcDirs = …”), whereas some are … something else? What is ‘exclude’ here, anyways?
Again: please point me to the right documentation. Despite spending a week or two with Gradle on-and-off over the last couple of months, I still feel like I’m wallowing around in a very odd programming language that just doesn’t fit my preconceived notions of variables, methods, instance variables, etc. What am I missing?
Thanks!