BIRT with Maven

Tags:

We have a web application that is built with Wicket. Our reports are generated using the Eclipse  BIRT plugin. The reports are in a separate project, and are then assembled to a WAR file. There is a BIRT prototype WAR file that is used for that purpose. Here you can find out more about the integration with Tomcat.

The problem for me was how to automate the assembly and also how to keep track of changes I made in the BIRT’s code (like removing a button from a jsp file). Up until now, I used an ANT script that took from the local copy of the prototype everything it needed and zipped it as a WAR file.

Instead of that, we created a POM file that does everything for me. Now I keepall BIRT’s files such as jsp and html, in SVN. The only local copies are the jar library files that are needed by BIRT. We plan to put them in our archyfactory so even this won’t be from the local machine. Another option is to create a system environment that the pom will check the location of the libs from there.

The POM below is what we created.

Note

  • We use a parent pom, which is simple and used for versioning stuff
  • I copy the output WAR to a local location and then move it to our dev location.

Hope that helps.

<?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">
<parent>
<groupId>com.my.com</groupId>
<artifactId>my-com-parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.com</groupId>
<artifactId>reports-webapp</artifactId>
<packaging>war</packaging>
<name>company reports webapp</name>
<properties>
<birt.runtime.location>C:/java/birt-runtime-2_3_0/WebViewerExample</birt.runtime.location>
<birt.runtime.libs>${birt.runtime.location}/WEB-INF/lib</birt.runtime.libs>
<birt.runtime.platform>${birt.runtime.location}/WEB-INF/platform</birt.runtime.platform>
<birt.runtime.version>2.3.0</birt.runtime.version>
</properties>
<build>
<defaultGoal>package</defaultGoal>
<finalName>${artifactId}-${version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${basedir}/shared</directory>
<includes>
<include>**/*</include>
</includes>
<targetPath>shared</targetPath>
<filtering>false</filtering>
</resource>
<resource>
<directory>${birt.runtime.libs}</directory>
<includes>
<include>**/*</include>
</includes>
<targetPath>WEB-INF/lib</targetPath>
<filtering>false</filtering>
</resource>
<resource>
<directory>${birt.runtime.platform}</directory>
<includes>
<include>**/*</include>
</includes>
<targetPath>WEB-INF/platform</targetPath>
<filtering>false</filtering>
</resource>
</webResources>
</configuration>
<!--
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy final war</id>
<phase>package</phase>
<configuration>
<tasks>
<echo>Setting timestamp...</echo>
<tstamp>
<format property="timestamp" pattern="yyyy-MM-dd"/>
</tstamp>
<echo>timestamp is ${timestamp}</echo>
<echo>Copying war file...</echo>
<copy file="target/${artifactId}-${version}.war" tofile="c:/viewer-${timestamp}.war" preservelastmodified="true" overwrite="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!--
<plugin> <artifactId>maven-antrun-plugin</artifactId> <executions>
<execution> <phase>package</phase> <goals> <goal>run</goal> </goals>
</execution> </executions> <configuration> <tasks> <echo>Coping birt
platform ...</echo> <copy
todir="target/reports-webapp-0.1-SNAPSHOT/WEB-INF/lib"
preservelastmodified="true"> <fileset dir="${birt.runtime.libs}">
<include name="**/*" /> </fileset> </copy> <copy
todir="target/reports-webapp-0.1-SNAPSHOT/WEB-INF/platform"
preservelastmodified="true"> <fileset
dir="${birt.runtime.platform}"> <include name="**/*" /> </fileset>
</copy> <echo>ZIP file...</echo> <zip destfile="c:/viewer-bew.war"
basedir="target/reports-webapp-0.1-SNAPSHOT" /> </tasks>
</configuration> </plugin>
-->
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api-2.5</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.my.com</groupId>
<artifactId>my-com-common</artifactId>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>commons-launcher</groupId>
<artifactId>commons-launcher</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>axis</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/axis.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>axis-ant</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/axis-ant.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.chart.engineapi
</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/chartengineapi.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>com.ibm.icu_3.8.1.v20080530</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/com.ibm.icu_3.8.1.v20080530.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>commons-cli-1.0</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/commons-cli-1.0.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>commons-discovery-0.2</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/commons-discovery-0.2.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>coreapi</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/coreapi.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>crosstabcoreapi</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/crosstabcoreapi.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>dataadapterapi</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/dataadapterapi.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>dteapi</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/dteapi.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>engineapi</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/engineapi.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>flute</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/flute.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>javax.wsdl_1.5.1.v200806030408</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/javax.wsdl_1.5.1.v200806030408.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>jaxrpc</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/jaxrpc.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>js</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/js.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>modelapi</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/modelapi.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>modelodaapi</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/modelodaapi.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>odadesignapi</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/odadesignapi.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.apache.commons.codec</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>
${birt.runtime.libs}/org.apache.commons.codec_1.3.0.v20080530-1600.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.birt.report.engine.dataextraction</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>
${birt.runtime.libs}/org.eclipse.birt.report.engine.dataextraction_2.3.0.v20080611.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.emf.common</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>
${birt.runtime.libs}/org.eclipse.emf.common_2.4.0.v200806091234.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.emf.ecore.xmi</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>
${birt.runtime.libs}/org.eclipse.emf.ecore.xmi_2.4.0.v200806091234.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.eclipse.emf.ecore</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>
${birt.runtime.libs}/org.eclipse.emf.ecore_2.4.0.v200806091234.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>org.w3c.css.sa</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>
${birt.runtime.libs}/org.w3c.css.sac_1.3.0.v200805290154.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>saaj</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/saaj.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>scriptapi</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/scriptapi.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>viewservlets</artifactId>
<version>${birt.runtime.version}</version>
<scope>system</scope>
<systemPath>${birt.runtime.libs}/viewservlets.jar
</systemPath>
</dependency>
</dependencies>
</project>

 

3
Your rating: None Average: 3 (1 vote)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

rv2n replied on Wed, 2009/08/05 - 2:23am

Hi , How do you create this porm file ??? Please let me knoew on earliest Thanks

Eyal Golan replied on Wed, 2009/08/05 - 8:50am in response to: rv2n

Hi,

I just took a "normal" pom file and just tweeked it until it was the way I wanted.

You are welcome to take the example code and use.

 Small remark,

This example forces the library files to be in the machine that  packages the war (for example my own computer).

we changed the whole pom file.

Now, there's a centralized location for the libraries.

I'll try to post soon the way we do it now.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.