Step 1 - pom.xml configuration for Vaadin 7
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.7</version>
</dependency>
</dependencies>
</dependencyManagement>
-
and then declare the usage of
vaadin-core
andmpr-v7
:
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-core</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>mpr-v7</artifactId>
</dependency>
Framework 7 dependency
When using MPR the minimum requirement for Vaadin 7 version is 7.7.14 or newer.
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
<version>7.7.17</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>7.7.17</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 legacy widget set.
Maven plugin version used at the moment is 7.7.17.
<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>7.7.17</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>
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>7.7.17</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.7</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-core</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>mpr-v7</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>
<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>
ABBF85AC-427F-48AC-8E40-2D6F509C378E