Hi Ghislain,
I don’t know your definition of easy, but mine has never applied to anything to do with OSGi!
Here’s how we got the Charts AddOn working (and a few others too, with similar methods).
Make a new maven project with the following pom:
<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>your.group.id</groupId>
<artifactId>osgi.vaadin.charts</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>OSGified Vaadin Charts</name>
<dependencies>
<dependency>
<groupId>com.vaadin.addon</groupId>
<artifactId>vaadin-charts</artifactId>
<version>1.0.0-beta1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<build>
<plugins>
<plugin> <!-- (2) START -->
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>com.vaadin.addon.charts.*, com.vaadin.addon.timeline.*</Export-Package>
<Import-Package>!com.google.gwt.*, !com.vaadin.client.*, *</Import-Package>
</instructions>
</configuration>
</plugin> <!-- (2) END -->
</plugins>
</build>
</project>
Use a single OSGi project to serve all the WidgetSets in a combined compilation, whose pom looks like:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>web.widgets</artifactId>
<name>Vaadin Custom Widget Bundle</name>
<parent>
<groupId>your.group.id</groupId>
<artifactId>whatever.artifact.sets.up.your.vaadin.compilation.and.bundlor.etc.configuration</artifactId>
<version>x.x.x</version>
</parent>
<dependencies>
<dependency>
<groupId>com.vaadin.addon</groupId>
<artifactId>vaadin-charts</artifactId>
<version>1.0.0-beta1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<version>${vaadin.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
<version>${vaadin.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/*.java</include>
<include>**/*.gwt.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${basedir}/src/main/webapp</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.springsource.bundlor</groupId>
<artifactId>com.springsource.bundlor.maven</artifactId>
<configuration>
<failOnWarnings>false</failOnWarnings>
<outputPath>${project.build.outputDirectory}</outputPath>
</configuration>
</plugin>
</plugins>
</build>
</project>
The settings are so that the compiled webapp, e.g. VAADIN.etc is included in the jar. I haven’t fixed this yet, but because of the ordering of the build goals you have to build this twice for the VAADIN resources to be included, sorry!
OSGiWidgetSet.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.vaadin.DefaultWidgetSet" />
<set-configuration-property name="devModeRedirectEnabled" value="true" />
<inherits name="com.vaadin.addon.charts.Widgetset" />
<inherits name="com.vaadin.addon.timeline.gwt.TimelineWidgetSet" />
</module>
template.mf:
Manifest-Version: 1.0
Bundle-Name: Vaadin Custom Widget Bundle
Bundle-ManifestVersion: 2
Bundle-SymbolicName: your.group.id.web.widgets
Excluded-Imports: *
Excluded-Exports: your.group.id.web.widgets.web.widgets.internal
Export-Package: VAADIN.widgetsets.your.groupid.web.widgets.OSGiWidgetSet,
VAADIN.widgetsets.your.groupid.web.widgets.OSGiWidgetSet.deferredjs,
VAADIN.widgetsets.your.groupid.web.widgets.OSGiWidgetSet.com_vaadin_addon_timeline
Then, in an application maven project:
<dependency>
<groupId>your.groupid</groupId>
<artifactId>osgi.vaadin.charts</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>vaadin-charts</artifactId>
<groupId>com.vaadin.addon</groupId>
</exclusion>
</exclusions>
</dependency>
and:
Import-Package: your.groupid.web.widgets;version="2.4.0"
I’ve probably missed something, so please come back with any questions.
Cheers, Dan.