Jump to content

BIRT Developer Center Download


Submitter

File Information

  • Submitted: Aug 07 2013 11:22 AM
  • Last Updated: Apr 28 2014 07:55 AM
  • File Size: 21.44KB
  • Views: 29287
  • Downloads: 74
  • Approved by: mwilliams
  • Approved on: 28 April 2014 - 07:55 AM
  • Summary: BIRT 4.3.0 has a lot of improvements over BIRT 4.2.2, and makes steps towards working better with Apache Maven than ever before. This article explains some gotchas and provides some code to avoid them.
  • Content Type: Designs & Code
  • BIRT Version: 4.3

Download Using BIRT 4.3.0 with Maven

- - - - -
4.3.0 maven Maven



Screenshots
Integrating BIRT (POJO engine) with maven ought to be as simple as placing the following dependency into your pom.xml:
<dependency>
  <groupId>org.eclipse.birt.runtime</groupId>
  <artifactId>org.eclipse.birt.runtime</artifactId>
  <version>4.3.0</version>
</dependency>
Unfortunately as soon as you do that you run into the first problem: there is a dependency on a private build of Apache POI that is not in maven. To work around this you can exclude that build of POI and bring in the full version:
<dependency>
  <groupId>org.eclipse.birt.runtime</groupId>
  <artifactId>org.eclipse.birt.runtime</artifactId>
  <version>4.3.0</version>
  <exclusions>
    <exclusion>
      <artifactId>org.apache.poi</artifactId>
      <groupId>org.eclipse.birt.runtime</groupId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.apache.poi</groupId>
  <artifactId>poi</artifactId>
  <version>3.9</version>
</dependency>
That will work, but it still has a few problems:
  • Although the main Apache POI classes have been excluded from the mavenised BIRT, they have failed to remove a lot of other classes (e.g. the XML beans schema classes for the MS Office file formats).

    The inclusion of these files doesn't stop BIRT from working as long as you are using POI 3.9, though they do bloat the resulting jar.

    If you want to use POI 3.10 the inclusion of these files could present real problems as that will come with (probably different) versions.
  • BIRT comes with the SpudSoft BIRT Excel Emitters, which makes it difficult to replace them with newer versions from BitBucket.
So, if you want to use a new version of either POI or the SpudSoft Excel Emitters (which I recommend) you have to take more steps.

The approach to take is to use the maven shade plugin to modify the BIRT jar file, stripping out the unwanted files and, as a bonus, replacing any files within the jar that are found to contain bugs.

The attached zip file contains a complete maven project that results in a new BIRT jar file that you can deploy to your local maven repository.

At a minimum the maven shade project needs to contain the following files:
  • /pom.xml
  • /src/main/resources/plugin.xml
    \nModified to remove the built-in version of the SpudSoft Excel Emitters.
  • /src/main/resources/META-INF/MANIFEST.MF
    \nModified to remove all the hashes for the compiled jars.
The key parts of the pom.xml are the base dependency:
<dependency>
	<groupId>org.eclipse.birt.runtime</groupId>
	<artifactId>org.eclipse.birt.runtime</artifactId>
	<version>4.3.0</version>
	<exclusions>
		<exclusion>
			<groupId>org.eclipse.birt.runtime</groupId>
			<artifactId>org.apache.poi</artifactId>
		</exclusion>
	</exclusions>
</dependency>
and the maven shade configuration:
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-shade-plugin</artifactId>
	<version>2.0</version>
	<configuration>
		<createSourcesJar>true</createSourcesJar>
		<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
		<artifactSet>
			<includes>
				<include>org.eclipse.birt.runtime:org.eclipse.birt.runtime</include>
			</includes>
		</artifactSet>
		<filters>
			<filter>
				<artifact>org.eclipse.birt.runtime:org.eclipse.birt.runtime</artifact>
				<excludes>
					<exclude>META-INF/*.SF</exclude>
					<exclude>META-INF/*.DSA</exclude>
					<exclude>META-INF/*.RSA</exclude>
					<exclude>org/apache/**</exclude>
					<exclude>org/dom4j/**</exclude>
					<exclude>org/eclipse/birt/report/engine/emitter/excel/**</exclude>
					<exclude>org/openxmlformats/**</exclude>
					<exclude>org/w3c/**</exclude>
					<exclude>schemaorg_apache_xmlbeans/**</exclude>
					<exclude>schemasMicrosoftCom*/**</exclude>\n					<exclude>uk/co/spudsoft/**</exclude>
				</excludes>
			</filter>
		</filters>
	</configuration>
	<executions>
		<execution>
			<phase>package</phase>
			<goals>
				<goal>shade</goal>
			</goals>
		</execution>
	</executions>
</plugin>
As a bonus the zip also contains a replacement for the file /src/main/java/org/eclipse/birt/report/engine/executor/ListingElementExecutor.java which fixes BIRT bug 413607.

When you use the jar file that this produces you must ensure that you add in a dependency for the correct version of POI and the SpudSoft Excel Emitters (which I'm afraid are not in maven yet, you should add them to your local maven repository manually).

I hope this is helpful to someone.




Your are a real Hero! I did add this Lib to my maven-repo and add it as an dependency to my TestApplication.

 

It works fine!

 

my Main-Class Code:

 

package de.bla;
 
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.*;
import org.eclipse.core.internal.registry.RegistryProviderFactory;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
 
 
public class FunGenerator {
 
    /**
     * Current Logger.
     */
    //private static org.apache.log4j.Logger LOG = Logger.getLogger(FunGenerator.class);
 
 
    public static void main (String[] args) {
        String reportDesignFilePath = "C:\\AngryBIRT\\reports\\empty_report.rptdesign";
        //String birtHomeDir = "C:\\AngryBIRT\\birt-engine\\ReportEngine";
        String logDir = "C:\\log";
        //String configDir = "";
        String resourcesDir = "C:\\AngryBIRT\\resources\\";
        String outputDir = "C:\\AngryBIRT\\output";
 
        IReportEngine engine = null;
        EngineConfig config = null;
        FileInputStream fileInputStream = null;
 
        try {
//read this in www
            System.setProperty("RUN_UNDER_ECLIPSE", "false");
            config = new EngineConfig();
 
            //config.setEngineHome(birtHomeDir);
            config.setLogConfig(logDir, Level.ALL);
            // important for BIRT to know resources
            config.setResourcePath(resourcesDir);
            // Render Option
            PDFRenderOption PDF_OPTIONS = new PDFRenderOption();
            // Default Render Option
            config.setDefaultEmitter("pdf", PDF_OPTIONS.getEmitterID());
            // startup this config
 
            Platform.startup(config);
 
            // create Report Engine
            final IReportEngineFactory FACTORY = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
            engine = FACTORY.createReportEngine(config);
 
            fileInputStream = new FileInputStream(reportDesignFilePath);
 
            IReportRunnable design = engine.openReportDesign(fileInputStream); // engine.openReportDesign("");
 
            IRunAndRenderTask task = engine.createRunAndRenderTask(design);
            task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, FunGenerator.class.getClassLoader());
            File reportDesignFile = new File(reportDesignFilePath);
            String outputFilePath = outputDir + "\\" + reportDesignFile.getName().replace(".rptdesign", ".pdf");
            File pdfFile = new File(outputFilePath);
            if (!pdfFile.exists()) {
                pdfFile.getParentFile().mkdirs();
            }
            PDF_OPTIONS.setOutputFileName(outputFilePath);
            PDF_OPTIONS.setOutputFormat("pdf");
            // set the render option
            task.setRenderOption(PDF_OPTIONS);
            // runs the report and generate output.
            task.run();
            // close the report.
            task.close();
            // free engine
            engine.destroy();
            System.out.println("done");
        } catch (BirtException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            // shutdown Platform
            Platform.shutdown();
            // release registries
            RegistryProviderFactory.releaseDefault();
            try {
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
 
}
 
 
 
Note:
 
i dont need set BIRTHome
 
i used jdk 1.6_45
 
the Report has a text nothing else.
 
I working on the integrate of the excel emitter and poi and I will post it here (soon/later).
 
GREAT WORK YayTay, I dont know why BIRT is "USER-UNFRIENDLY" or it is a Layer-8 Problem!
 
(BIRT is great, too. Since Dec 2015 i was frustrated, cause of didn't work out of eclipse)



0 user(s) are online (in the past 1 minutes)

0 members, 0 guests, 0 anonymous users