Hi,
I have organized my Vaadin Maven project, which uses add-ons, as follows:
- A parent project, which basically just defines two Maven modules.
- A widgets project, which specifies the add-ons in a GWT module. GWT compiles the widgets and adds them to a jar file.
- The actual project, which uses the maven-dependency-plugin to unpack the jar file from the widgets project (more precisely the VAADIN folder) into the webapp.
The setup is slightly more complicated than with a simple Maven project. However, the obvious advantage is that I need to run GWT very rarely - only if the widget set is updated. What’s more, if I use a single add-on only, the jar file from the widgets project is reusable. Add-on authors could provide this, taking away the pain of using GWT for users, which need their add-on only and nothing else.
What do you think? More details below.
Jochen
The parent POM is really simple:
<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.projects.vaadindemo</groupId>
<artifactId>vaadindemo-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>vaadindemo-widgets</module>
<module>vaadindemo</module>
</modules>
</project>
Here’s the widgets module:
<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>
<parent>
<groupId>com.mycompany.projects.vaadindemo</groupId>
<artifactId>vaadindemo-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.mycompany.projects.vaadindemo</groupId>
<artifactId>vaadindemo-widgets</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin</artifactId>
<version>6.5.2</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Add-ons are following, I take TreeTable as an example. -->
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>vaadin-treetable</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<!-- Version 2.1.0-1 works at least with Vaadin 6.5 -->
<version>2.1.0-1</version>
<configuration>
<webappDirectory>${project.build.outputDirectory}/VAADIN/widgetsets</webappDirectory>
<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
<runTarget>clean</runTarget>
</configuration>
<executions>
<execution>
<goals>
<goal>resources</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Updates Vaadin 6.2+ widgetset definitions based on project dependencies -->
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<goals>
<goal>update-widgetset</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And, finally, here’s the actual project, which replaces use of GWT with the maven-dependency-plugin:
<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>
<parent>
<groupId>com.mycompany.projects.vaadindemo</groupId>
<artifactId>vaadindemo-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.mycompany.projects.vaadindemo</groupId>
<artifactId>vaadindemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.mycompany.projects.vaadindemo</groupId>
<artifactId>vaadindemo-widgets</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${webappDirectory}</outputDirectory>
<includeArtifactIds>vaadindemo-widgets</includeArtifactIds>
<includes>VAADIN/**/*</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<webappDirectory>${project.build.directory}/${project.artifactId}</webappDirectory>
</properties>
</project>