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
Now, open the
build.gradle file and let's declare a task by adding the following line:
We should be able to see this task on the command line as follows:
$ gradle tasks ... Other tasks ----------- helloWorld ...
Here, we have successfully created a task object called
helloWorld. Tasks ...