IntelliJ IDEA
Last updated
Last updated
Source code for this tutorial is available on github.com/vaadin-on-grails-3/hello-world.
Grails support in IntelliJ IDEA is added through Grails plugin. Make sure it is installed in your IntelliJ IDEA before you start with the tutorial.
Create new project from IDEA menu. Click on New..
item in the menu and then on Project...
.
If it is your first Grails project in IDEA, click on ...
next to Grails SDK Home and provide path to your Grails folder. It will add Grails into IDEA. When you are done, click on Next
.
Fill in the name of the project and where the project should be created. Then click on Finish
button.
Warning: sometimes, IDEA is not able to create Grails project and you end up with weird errors. In that case, try to upgrade IDEA version or run
grails create-app my-app
in console. Then open the project in IDEA and follow the next steps.It takes more time to create new project first time.
When IDEA opens the newly created project, find and open build.gradle file. We need to add build and project dependencies to get the integration with Vaadin working.
Copy paste these lines into buildscript section. Check the print screen for places where to put these lines.
Then add these two lines into project dependency section:
The latest version of the plugin is always available on https://bintray.com/ondrej-kvasnovsky/plugins.
Now we have all dependencies available and we can run vaadin-quick-start
Gradle target to create mandatory files. vaadin-quickstart
command creates MyUI.groovy
, VaadinConfig.groovy
and removes URL mapping inside UrlMapping.groovy
.
Now we are able to run our application.
Here is how Grails run configuration looks like, in case we need to create it for our project.
When the application is successfully started, we should see this UI in the browser.
In this step, we are going to do change in our Vaadin code and we will observe how changes are reflected in UI without server restart.
First we need to enable auto recompile
in IDEA. Open IDEA settings and check on Build project automatically
box.
Then open MyUI.groovy file and add a label into main layout.
Switch to browser and refresh the page. We should see the newly added label on UI.