The first step in getting working with Grails on the Raspberry Pi is, of course, installing Grails. I've been somewhat dreading this post because it's pretty hard to make installing software interesting, but it's necessary so we'll trudge through it and try to have a good time with it. If you've never worked with Groovy or Grails before, that's quite alright. I'll do my best to make sure that I keep things basic, but at the same time you might want to run through some Groovy or Grails tutorials (there are plenty out there). Also, feel free to ask questions. My goal is to help you get a web site up and running on the Raspberry Pi.There are two ways to install Grails. One way is to download it yourself, and the right way is to install SDKMAN and use it to install Grails for you. Follow the instructions on the Grails download page to install SDKMAN, but before you do make sure that you have "zip" installed first via:
sudo apt-get install zip
Note: SDKMAN will prompt you to run the following command after it installs:
Please open a new terminal, or run the following in the existing one:
Don't skip this step, else you'll get errors complaining that "sdk: command not found". Once SDKMAN is installed, install Grails via:
sdk install grails
Seriously, that's all it takes. Since you didn't pass a specific version to SDKMAN it'll grab the latest version and install it (which is 3.2.7 as of the time this post was published).
Well, I kinda lied - if you actually want to run Grails, you'll have to set the JAVA_HOME environment variable so that Grails knows where Java is. After you set JAVA_HOME, run:
Since Grails uses the Groovy language, it'll also install the required Groovy version, but I typically like to also install a standalone version of Groovy for one off scripts and testing purposes. To install Groovy, just do:
sdk install groovy
I typically also create a folder called "Projects" in my home directory so feel free to do something similar at this point. If you want to create a simple test Groovy script, create a file called test.groovy and enter the following using nano (or vi if you're crazy):
println new Date().format('MM-dd-yyyy')
Run it from the command line with:
And it'll output the current date.
And that's all it takes to get Groovy and Grails installed on the Raspberry Pi. In the next post we'll look at creating a slightly more complex Groovy script to illustrate how easy it is to use for simple scripting and even more complex tasks.
I’ve written about messaging many, many times on this blog. And for good reason, too. It’s a popular subject that developers can’t seem to get enough of...
Security is the most important aspect of your web application. Fortunately, there are tools available to help make life much easier when dealing with things...
When adopting cloud-native technologies and certain architectures such as the microservice pattern, observability and monitoring become a huge need and...