Documentation

Documentation versions (currently viewingVaadin 23)

You are viewing documentation for Vaadin 23. View latest documentation

Step 1 - pom.xml configuration for Vaadin 8

Maven setup

MPR is part of Vaadin, so the supported version of the project is set for you when importing the platform in your project. In other words, you only need to define the platform version:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <type>pom</type>
            <scope>import</scope>
            <version>23.5.8</version>
        </dependency>
    </dependencies>
</dependencyManagement>
  1. and then declare the usage of vaadin-core and mpr-v8:

<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-core</artifactId>
</dependency>
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>mpr-v8</artifactId>
</dependency>

Framework 8 dependency

When using MPR the minimum requirement for Vaadin 8 version is 8.6.0 or newer:

<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-server</artifactId>
    <version>8.7.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-elemental</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-themes</artifactId>
    <version>8.7.0</version>
</dependency>
Note
You also need to remove the dependency on the vaadin-client-compiled, since a custom widget set is served by the MPR project.
Note
When using MPR you can’t use a Content Delivery Network (CDN) for the widget set. This means that the configuration <vaadin.widgetset.mode>cdn</vaadin.widgetset.mode> or <vaadin.widgetset.mode>fetch</vaadin.widgetset.mode> should be removed.

Maven Plugins

If not already added in your build section, you need to add the vaadin-maven-plugin for it to manage the custom widget set. Maven plugin version used at the moment is 8.7.0.

<build>
     <plugins>
         <plugin>
             <groupId>com.vaadin</groupId>
             <artifactId>vaadin-maven-plugin</artifactId>
             <version>8.7.0</version>
             <executions>
                 <execution>
                     <goals>
                         <goal>resources</goal>
                         <goal>update-widgetset</goal>
                         <goal>compile</goal>
                     </goals>
                 </execution>
             </executions>
         </plugin>
     </plugins>
 </build>

Vaadin 14 too requires a Maven plugin for processing frontend resources during development time. Because the vaadin-maven-plugin can only be defined with one version, you’ll have to use the flow-maven-plugin instead. This forces you to manually define the plugin version, since Maven doesn’t allow you to define a plugin version in the Bill-of-Materials (BOM).

<build>
     <plugins>
         <plugin>
             <groupId>com.vaadin</groupId>
             <artifactId>flow-maven-plugin</artifactId>
             <version>2.0.7</version>
             <executions>
                 <execution>
                     <goals>
                         <goal>prepare-frontend</goal>
                     </goals>
                 </execution>
             </executions>
         </plugin>
     </plugins>
 </build>

Logging

To display Flow application logs, any slf4j implementation should be added to the project. The easiest way would be to use slf4j-simple dependency:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.25</version>
</dependency>

Vaadin 7 compatibility package

If your project is using components from the Vaadin 7 compatibility package, then you also need to add:

<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-compatibility-server</artifactId>
    <version>8.7.0</version>
</dependency>

<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-compatibility-client</artifactId>
    <version>8.7.0</version>
    <scope>provided</scope>
</dependency>

Appendix: Sample pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>
    <artifactId>my-mpr-app</artifactId>
    <packaging>war</packaging>
    <version>0.1</version>

    <properties>
        <vaadin.version>8.7.0</vaadin.version>
        <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
        <!-- Flow version needs to be defined manually for Flow Maven plugin,
            because Maven BOMs don't support plugin versions or defining properties.
            The Flow version to use can be checked from vaadin-bom. -->
        <flow.version>2.0.7</flow.version>

        <slf4j.version>1.7.25</slf4j.version>
        <jetty.plugin.version>9.4.19.v20190610</jetty.plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <type>pom</type>
                <scope>import</scope>
                <version>23.5.8</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>mpr-v8</artifactId>
        </dependency>

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-server</artifactId>
            <version>${vaadin.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jsoup</groupId>
                    <artifactId>jsoup</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.gwt</groupId>
                    <artifactId>gwt-elemental</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-themes</artifactId>
            <version>${vaadin.version}</version>
        </dependency>

        <!-- Vaadin 7 compatibility packages -->
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-compatibility-server</artifactId>
            <version>${vaadin.version}</version>
        </dependency>

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-compatibility-client</artifactId>
            <version>${vaadin.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <version>${vaadin.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>resources</goal>
                            <goal>update-widgetset</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Since the Vaadin Maven plugin can only be defined with one version,
                The Flow Maven plugin is used instead for handling Vaadin 14+ frontend
                resources for development and production builds. -->
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>flow-maven-plugin</artifactId>
                <version>${flow.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-frontend</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- The Jetty plugin allows us to test the development build by
				running jetty:run on the command line. -->
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty.plugin.version}</version>
                <configuration>
                    <scanIntervalSeconds>2</scanIntervalSeconds>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

80D29A33-0103-4815-9C65-FBB78871F515