Basic query on gradle task syntax

Hi,

I am a Java developer and just joined a project which already uses Gradle. In build.gradle file, I have statements like below

springBoot {
backupSource = false
}

checkstyle {
configProperties = [basedir: projectDir]
}

task bowerInstall(type: Exec, dependsOn: npmInstall) {
commandLine ‘node’, ‘node_modules/bower/bin/bower’, ‘install’, ‘-F’, ‘-s’
}

task gulpBuild(type: Exec, dependsOn: [npmInstall, bowerInstall]) {
commandLine ‘node’, ‘node_modules/gulp/bin/gulp’, ‘build’, ‘–release’, ‘–silent’
}

Here I understand “bowerInstall” and “gulpInstall” are custom taks as they have the keyword “task” in the beginning. But what about other statements like “springBoot” and “checkstlye”. It doesnt have the “task” prefix, but it looks like task. Are they called as tasks ? Can you please clarify my doubt ? Also do you think learning groovy syntax mandatory to write the build.gradle file ?

Well they can be anything.

Actually, when you see

task XXX(YYY) {
/// ZZZ
}

you are calling the task method on the project instance that you build.gradle file delegates to.
Its documentation can be found here
It’s a convenient way to create a new task on the given project.

The other code blocks are only one Groovy way to declare properties.
eg checkstyle corresponds to the project.checkstyle property.
This property happens to be of type CheckstyleExtension, but it could be anything.
Using a closure allows to further configure what’s inside the checkstyle property.
You could have written checkstyle.configProperties = [basedir: projectDir] with the same result.
The closure allows to configure several things from checkstyle at the same time.

Note that you can configure tasks as well like this.
A task, when created, is added to the project’s tasks container tasks
so the following works as well

tasks.bowerInstall {
   //configure here stuffs from the task
}