Integrating BIRT into Your Maven Build - A Work In Progress
Join the DZone community and get the full member experience.
Join For FreeWhen ever I undertake a project I always looks for an opportunity to use at least one new technology so as to continually increase the number of tools I have in my toolbox, so for a recent project I took the opportunity to use BIRT, the Eclipse's reporting engine. In the past, before Birt was available, I had made use of JasperReports. The biggest challenge I found with Jasper Reports at the time was the visual report designer. Although there was a GUI designer available,namely iReports, it wasn't the greatest, this might have changed, but this was one of my biggest reasons for deciding to use BIRT.
I am happy to say that report creation with BIRT was a breeze, with a few clicks of the button, one can generate a decent looking report. However I didn't get the afternoon off. Instead I had to struggle to try and integrate BIRT into my web application. The two challenges I faced were:
- Integrating the BIRT dependencies into a maven build process, and
- Integrating the runtime engine into your application
Maven and BIRT Dependencies
Basicaly BIRT has not been mavenised. For one, the BIRT dependencies are not readily available in the maven2 public repositories and secondly finding a complete list of dependencies was a challenge. There are a few dependencies, so having to download and then install the dependencies in your own local repository, although an option, can be painful. Luckily the kind folks at JBoss have a maven repository with the Birt core dependencies. So first you will need to add an entry for the JBoss maven repo to your pom.xml.
<repositories>
<repository>
<id>JBoss</id>
<name>JBoss Repository</name>
<layout>default</layout>
<url>http://repository.jboss.org/maven2</url>
</repository>
.....
</repositories>
Then you need to add the BIRT dependencies. Currently the JBoss repo does not have the latest BIRT 2.5.0 dependencies. I assume this is because Eclipse 3.5, with BIRT 2.5.0 has just come out and they will be added in due course. First I set a property to the version of BIRT I am using.
<properties>
<birt.version>2.3.2</birt.version>
</properties>
Then reference this in the pom dependencies section.
<dependencies>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>chartengineapi</artifactId>
<version>${birt.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>coreapi</artifactId>
<version>${birt.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>dataadapterapi</artifactId>
<version>${birt.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>engineapi</artifactId>
<version>${birt.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>modelapi</artifactId>
<version>${birt.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>scriptapi</artifactId>
<version>${birt.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>dteapi</artifactId>
<version>${birt.version}</version>
</dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>rhino</groupId>
<artifactId>js</artifactId>
<version>1.6R7</version>
</dependency>
<dependency>
<groupId>apache-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
......
</dependencies>
There may be more dependencies depending on the export format that you use. I only made use of PDF format for the reports. If you find other dependencies please add them in the comments. The last two dependencies where a bit more difficult to track down but they are available in the JBoss repo. For 2.5.0 you may have to experiment, of google, for the correct versions of these jars. With the above you can now happily compile your web app, but it won't run as you have not included the BIRT runtime dependencies. BIRT is an OSGI application and as such requires a stripped down version of the OSGI runtime to work.
How to Include BIRT OSGI Runtime Requirements?
The BIRT OSGI runtime has over 116 dependencies! Besides the large number of dependencies, the runtime files need to be in specific directories, namely plugins and configuration, as well. Although I am sure there is a smart way to do this with maven, that is a bit beyond my current maven skill level. The solution I used was to copy the two directories from the matching runtime archive, to the WEB-INF directory. The war plugin then automatically copies the runtime over as part of the war plugin packaging process.
Help With The Documentation
If anyone has some tips on how better to integrate BIRT with Maven, please let me know.
Opinions expressed by DZone contributors are their own.
Trending
-
File Upload Security and Malware Protection
-
Top 10 Pillars of Zero Trust Networks
-
Merge GraphQL Schemas Using Apollo Server and Koa
-
Unlocking the Power of AIOps: Enhancing DevOps With Intelligent Automation for Optimized IT Operations
Comments