How do I start a new vaadin project in IntelliJ IDEA?

intellij-idea, java, vaadin

Solution

Here's how I did this.

First create the Vaadin project using the maven artefact.

C:\dev> mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.0.4 -Dpackaging=war
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [com.vaadin:vaadin-archetype-application:7.0.4] found in catalog remote
Define value for property 'groupId': : maba
Define value for property 'artifactId': : vaadin-app
Define value for property 'version':  1.0-SNAPSHOT: :
Define value for property 'package':  maba: :
Confirm properties configuration:
groupId: maba
artifactId: vaadin-app
version: 1.0-SNAPSHOT
package: maba
 Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: vaadin-archetype-application:7.0.4
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: maba
[INFO] Parameter: artifactId, Value: vaadin-app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: maba
[INFO] Parameter: packageInPathFormat, Value: maba
[INFO] Parameter: package, Value: maba
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: maba
[INFO] Parameter: artifactId, Value: vaadin-app
[INFO] project created from Archetype in dir: C:\dev\vaadin-app
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.122s
[INFO] Finished at: Fri Apr 19 08:05:49 CEST 2013
[INFO] Final Memory: 12M/152M
[INFO] ------------------------------------------------------------------------
C:\dev>

Then step into the newly created directory and run `mvn install` just to get all dependencies and have a fresh start.

c:\dev\vaadin-app> mvn install
[INFO] Scanning for projects...
    ...
    ------ LOTS OF STUFF GOING ON ------
    ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:30.373s
[INFO] Finished at: Fri Apr 19 08:13:07 CEST 2013
[INFO] Final Memory: 24M/296M
[INFO] ------------------------------------------------------------------------

Now open the project by pointing to the newly created `pom.xml`.

Everything looks fine. Choose to configure the GWT framework in the green box in the upper right corner.

Now choose the `Edit Configurations...` drop-down.

Choose the `GWT Configuration`.

Give it a name and choose the `Module` from the drop-down.

Now you will have the option to choose `GWT Module to load` with two options at the moment.

I choose to run the application. In this case it will give you an error.

This seems to be a known error at the moment. You'll have to add the `vaadin-client-compiler.jar` to classpath manually.

Press the `Project Structure` button in the toolbar.

Select `Dependencies` tab for the `vaadin-app` and choose to add `Jars or directories...`.

Navigate to your local maven repository and find the `vaadin-client-compiler-<version>.jar`.

On Mac OS and Linux/Unix, this will found at: `~/.m2/repository/com/vaadin/vaadin-client-compiler/7.0.4/...`

Press `Ok` and `Ok` again in the `Project Structure` window.

Now once again run the application. No more errors.

Now, I'm not a Vaadin expert so from here you're on your own.

Have fun!

Problem

The answer based on the maven archetype approach works. I will update and accept an answer based on using the built in wizard if the IntelliJ wizard/template for Vaadin is ever fixed.* I managed to create a new project using the maven archetype from a terminal window, and then import that into IntelliJ IDEA, configured the GWT facet, but now when I run it says: ``` "Error running unnamed: No GWT Modules found in 'projectname'" ``` I confess to being a total beginner at Java, IntellIJ, and Vaadin, not to mention GWT. I also tried creating a new Vaadin projet using the native Vaadin plugin that comes with IntelliJ IDEA (Ultimate). I am using Ultimate, but it's a trial. Update:: Originally I could not see any Vaadin projects in the New Project window's list of available project templates. That's because I was confused by the two-levels-of-new-projects idea in IntelliJ's new project wizard. Sorted that out now. Update2:: I can follow the steps from EITHER of the two answers below and get a project that builds but it doesn't run. I assume I was right to add the GWT run-target, because before I do that the Run menu is entirely grayed out. I believe it is grayed out because there are no modules listed in the modules list for the GWT facet. I assume that I must create a new Run/Debug configuration which must be one of the following, and GWT made some sense since vaadin is based atop GWT: After I add the GWT I still get the same error as I got originally when I started from the maven archetype: No GWT modules. And I have no idea what people are talking about picking from a drop down module... Update3 Still was unable to get either solution below to work. Stuck at this screen and unable to get it to show any modules in the "GWT modules to load" combo box which remains grayed out. I believe this is the drop down module that I am supposed to pick, but nothing below tells me how to get it to be un-grayed-out (enabled): I eventually managed to (a) add the GWT facet manually, (b) configure it, and (c) now it will run. That leads to a runtime error (the app does not open in the web browser, but it is clear that it's very close to working.)

Original source