Running Groovy Files with Gradle

12:41 PM , , 0 Comments


How do you run groovy files with gradle?

Running groovy files in gradle is very easy. Here is a complete example.
For this tutorial you will need the following:

* Gradle 3.4.1
* Groovy 2.4.7
* Java 8 or higher

First we will need to create the groovy file that we will execute. In our example, let's call it MyMainClass.groovy. In this file we're just printing a basic hello world example.
Then we will need a build.gradle file. In this file, we will have to define our dependencies. Next, we have defined a task called execute. This task will call main.groovy.MyMainClass when run.
To run the script, we can do this in the terminal:

That's it! You should be able to see hello world on the terminal!


Meep Musings

I am a free lamb who loves travels around the world, exploring different cultures, meeting interesting people and I talking about anything and everything under the sun. :)

No comments :