Writing a build script
In the first chapter, we have already written our first build script. Let's create a similar build script with a simple task. Gradle will look for a file with the name build.gradle
in the current directory. The build.gradle
file contains the tasks that make up our project. In this example, we define a simple task that prints out a simple message to the console:
// Assign value to description property. project.description = 'Simple project' // DSL to create a new task using // Groovy << operator. task simple << { println 'Running simple task for project ' + project.description }
If we run the build, we see the following output in the console:
:simple Running simple task for project Simple project BUILD SUCCESSFUL Total time: 0.57 secs
A couple of interesting things happen with this small build script. Gradle reads the script file and creates a Project
object. The build script configures the Project
object, and finally, the set of tasks...