The first Gradle build script

So we are now ready to get our feet wet and see our first Gradle script in action. Let's create a file called build.gradle in the hello-gradle directory. Unless the build file path is provided using the --build-file option, Gradle treats the current directory as a project root and tries to find the build.gradle file there. If we have used Ant or Maven earlier, we can relate this file with build.xml or pom.xml, respectively.

Now, open the build.gradle file and let's declare a task by adding the following line:

task helloWorld

We should be able to see this task on the command line as follows:

$ gradle tasks
Other tasks

Here, we have successfully created a task object called helloWorld. Tasks ...

Get Gradle Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.