2.6. Using Vaadin with Maven
Maven is a commonly used build and dependency management system. The Vaadin core library and all Vaadin add-ons are available through Maven. You can use a Maven with a front-end from Eclipse or NetBeans, or by using the command-line as described in this section.
In addition to regular Maven, you can use any Maven-compatible build or dependency management system, such as Ivy or Gradle. For Gradle, see the Gradle Vaadin Plugin. Vaadin Plugin for Eclipse uses Ivy for resolving dependencies in Vaadin projects, and it should provide you with the basic Ivy configuration.
2.6.1. Working from Command-Line
You can create a new Maven project with the following command (given in one line):
$ mvn archetype:generate \
The parameters are as follows:
The group ID of the archetype is
com.vaadin for Vaadin archetypes.
The archetype ID. Vaadin 7 currently supports
vaadin-archetype-application archetype for server-side applications and
vaadin-archetype-widget for client-side widget development projects.
Version of the archetype to use. This should be
LATEST for normal Vaadin releases. For prerelease versions it should be the exact version number, such as
A Maven group ID for your project. It is normally your organization domain name in reverse order, such as
com.example. The group ID is also used as a prefix for the Java package in the sources, so it should be Java compatible - only alphanumerics and an underscore.
Identifier of the artifact, that is, your project. The identifier may contain alphanumerics, minus, and underscore. It is appended to the group ID to obtain the Java package name for the sources. For example, if the group ID is
com.example and artifact ID is
myproject, the project sources would be placed in
Initial version number of your application. The number must obey the Maven version numbering format.
How will the project be packaged. It is normally
Creating a project can take a while as Maven fetches all the dependencies. The created project structure is shown in Figure 2.8, “A New Vaadin Project with Maven”.
Figure 2.8. A New Vaadin Project with Maven
2.6.2. Compiling and Running the Application
Before the application can be deployed, it must be compiled and packaged as a WAR package. You can do this with the
package goal as follows:
$ mvn package
The location of the resulting WAR package should be displayed in the command output. You can then deploy it to your favorite application server.
The easiest way to run Vaadin applications with Maven is to use the light-weight Jetty web server. After compiling the package, all you need to do is type:
$ mvn jetty:run
The special goal starts the Jetty server in port 8080 and deploys the application. You can then open it in a web browser at
2.6.3. Using Add-ons and Custom Widget Sets
If you use Vaadin add-ons that include a widget set or make your custom widgets, you need to enable widget set compilation in the POM. The required configuration is described in Section 16.4, “Using Add-ons in a Maven Project”.