Eclipse BIRT 3.7.2 with Maven

birt with maven

Since Eclipse BIRT 3.7 the report engine is delivered as a simple Pojo based report API it currently has no support for maven bundleing either.

You can find a Migration Guide for the new Pojo Runtime Engine here http://wiki.eclipse.org/Birt_3.7_Migration_Guide .

But bundleing BIRT in your application built with maven is a boring task. So i found an interesting article of how to use birt with maven using system bundles. This is not a bad idea but it is not really portable and even far from bundleing BIRT into your WAR or EAR application.

After reading this article i found another approach of using BIRT with Maven which i will describe here.

First, the following assumptions have been made:

  • you using an Artifact Proxy like Artifactory, Nexus, …
  • you know Maven and can deploy artifacts to your Artifact Proxy
  • you using maven 3

1. Download Birt Runtime and extract to a Folder

You can download BIRT Runtime from the following page http://download.eclipse.org/birt/downloads/

2. Create Simple POM for deploy and plugin definitions

After downloading, create a folder maven-convert under the extracted BIRT Runtime and place the following POM snippet inside the folder.

This POM is only for managing which upload wagon extensions to use and which version of the eclipse-maven-plugin we want to use. The eclipse-maven-plugion is responsible for uploading the BIRT artifacts to your Artifact Proxy and generate Maven POM’s for each artifact.

<?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>
<groupId>birt</groupId>
<artifactId>birt-convert</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<build>
<extensions>
<!-- Enabling the use of WebDav -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<version>2.0</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

3. Remove non osgi plugins from Birt folder

After we extracted the BIRT Runtime to a user defined Folder and created the maven-convert folder below, we copy all libs from birt-runtime-3_7_2/ReportEngine/lib to birt-runtime-3_7_2/maven-convert/plugins

Before we run the maven-eclipse-plugin we must remove some artifacts because they don’t have any bundling informations in their MANIFEST.MF headers. Also these artifacts aren’t osgi artifacts so the maven-eclipse-plugin can not determine the dependencies from it.

these are the artifacts that we must remove from the folder:

commons-cli-1.0.jar
flute.jar
Tidy.jar

4. Deploy birt eclipse plugins with maven-eclipse-plugin to your Artifact Proxy

Now we are ready to deploy the artifacts in the maven-convert/plugins folder to our Artifact Proxy.

Just execute the following command staying in the Folder maven-convert. (modify the host of your artifact proxy)
$M2_HOME/bin/mvn -e eclipse:to-maven -DdeployTo=enterprise::default::dav:http://your-artifact-proxy-host/ext-releases-local -DeclipseDir=.

5. Insert Birt dependencies into your project pom

After you have done the deploy of all the birt runtime artifacts we will modify the pom of our project that will use the birt runtime.

Note that this snippet contains specific postgresql oda connectors which are not needed if you use an other database.

Here is the POM Snippet:

<!-- icu4j and js rhino -->
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
</dependency>
<dependency>
<groupId>rhino</groupId>
<artifactId>js</artifactId>
<version>1.7R2</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
<!-- fop transitively includes the complete batik package -->
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<artifactId>batik-script</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
<exclusion>
<artifactId>avalon-framework-impl</artifactId>
<groupId>org.apache.avalon.framework</groupId>
</exclusion>
<exclusion>
<artifactId>avalon-framework-api</artifactId>
<groupId>org.apache.avalon.framework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.w3c.css</groupId>
<artifactId>sac</artifactId>
<version>1.3.0-v200805290154</version>
</dependency>
<dependency>
<groupId>org.w3c.dom</groupId>
<artifactId>svg</artifactId>
<version>1.1.0-v201011041433</version>
</dependency>
<dependency>
<groupId>net.sf.jtidy</groupId>
<artifactId>jtidy</artifactId>
<version>r938</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>common</artifactId>
<version>3.6.0-v20110523</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>runtime</artifactId>
<version>3.7.0-v20110110</version>
<exclusions>
<exclusion>
<artifactId>app</artifactId>
<groupId>org.eclipse.equinox</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>app</artifactId>
<version>1.3.100-v20110321</version>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>services</artifactId>
<version>3.3.0-v20110513</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
<version>3.7.2-v20120110-1415</version>
</dependency>
<dependency>
<groupId>org.eclipse.update</groupId>
<artifactId>configurator</artifactId>
<version>3.3.100-v20100512</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>expressions</artifactId>
<version>3.4.300-v20110228</version>
</dependency>
<dependency>
<groupId>org.eclipse.emf.ecore</groupId>
<artifactId>xmi</artifactId>
<version>2.7.0-v20120123-0926</version>
</dependency>
<dependency>
<groupId>org.eclipse.datatools.connectivity</groupId>
<artifactId>oda</artifactId>
<version>3.3.3-v201110130935</version>
<exclusions>
<exclusion>
<artifactId>icu</artifactId>
<groupId>com.ibm</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.datatools.connectivity.oda</groupId>
<artifactId>consumer</artifactId>
<version>3.2.5-v201109151100</version>
</dependency>
<dependency>
<groupId>org.eclipse.datatools.enablement</groupId>
<artifactId>postgresql</artifactId>
<version>1.1.0-v201110070445</version>
<exclusions>
<exclusion>
<artifactId>icu</artifactId>
<groupId>com.ibm</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.datatools.enablement.postgresql</groupId>
<artifactId>dbdefinition</artifactId>
<version>1.0.2-v201110070445</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
<dependency>
<groupId>org.eclipse.datatools.connectivity.oda</groupId>
<artifactId>flatfile</artifactId>
<version>3.1.2-v201112081200</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>xml-resolver</groupId>
<artifactId>xml-resolver</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>runtime</artifactId>
<version>3.7.2-v20120214-1408</version>
</dependency>

6. Test if all is running fine

Instanciate  the Reportengine as it wer described in the BIRT documentation and run a simple report with the following code snippet. (this only opens the report)
InputStream inputStream = getClass().getResourceAsStream("/test.rptdesign");
// Open the report design
IReportRunnable design = engine.openReportDesign(inputStream);

Advertisements

1 Kommentar

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden /  Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden /  Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s