Being in the process of moving from Eclipse to IntellJ IDEA, I was looking for a way to set up a new Vaadin 7 project (or actually a “module” as it’s called in IntelliJ) using Maven. I wanted to be able to deploy to Tomcat, preferably in a short cycle.
As I had to put together information from several sources and figure out some things by myself, I’m presenting the result of my research here.
Here we go:
1. Create a Maven project/module from the archetype
Either use an existing project or a new empty project in which you create a Maven module, or create a new Maven project. Whatever you choose, keep in mind that if you create a Maven (or any other) project and don’t change the name of the module, by default it will have the same name as the project and its root folder will be the same as the project root folder. If you plan to add more modules later this may not be what you want.
I chose to create a new Maven module in a new empty project that I created:
Choose File -> New Module. Select Maven. If not already present, add the archetype from group com.vaadin and with artifact id vaadin-archetype-application. For the version, just look up the latest one.
2. Adjust the POM
IDEA will have already opened the pom.xml file automatically. There is one change you must make: find the commented out dependency to the vaadin-client-compiler and uncomment it:
3. Package the project using Maven.
Open the Maven Projects tool window either by hovering over the icon in the lower left corner or by typing Ctrl-Shift-A and searching for Maven Projects. Then open Lifecycle and double-click package:
After a few minutes, the .war file should be built.
4. Configure the Tomcat server
If you haven’t already done this, you should at this point configure a new Tomcat server:
Choose Run -> Edit Configurations…, press the + icon and choose to add a new Local Tomcat Server.
Choose a name for the server and make sure to select ‘Update resources’ for the ‘On frame deactivation’ option:
Go to the Deployment tab. Click the + icon here to add an artifact. Select the exploded version of the .war file and press OK.
5. Enable HotSwap deployment
You need to make sure HotSwap deployment is enabled in the settings:
6. Start server in debug mode
Now you’re ready to start the server in debug mode:
You should see the Vaadin sample application at http://localhost:8080/.
Now when you make a code change, you can just press Ctrl+Shift+F9 to recompile and the classes will be reloaded.