Our first script
In the last section, we learned how to install Gradle. Now it's time create our very first Gradle script. This script will print Hello Gradle- This is your first script
on the console. Just open a text editor, type in the following three lines, and save the file as build.gradle
.
task helloGradle << { println 'Hello Gradle- This is your first script' }
Then execute the gradle helloGradle
command as follows:
$ gradle helloGradle :helloGradle Hello Gradle- This is your first script BUILD SUCCESSFUL Total time: 4.808 secs
So, what have we done here?
- We have a created a Gradle build script file called
build.gradle
. This is the default name given to a build file. You can give any name to the build file. However, to execute the script, ...
Get Mastering Gradle now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.