ADempiere/Jasper Batch Compile

From ADempiere
Revision as of 07:18, 8 June 2009 by Red1 (Talk) (categorizing)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Here's a little hint how to speed up the compilation of .jrmxl-Files within eclipse or netbeans. This might be helpful if you are using lots of Jasper-Templates and do not want do compile them one by one from iReport - well, in our case 29 templates were quite enough... Hope this helps some of you save a little time!

Add two new ant targets to your build.xml:

   <target name="delete-jasper-files">
       <property name="jasper.dir" value="${src}"/>
       <delete>
           <fileset dir="${jasper.dir}" includes="**/*.jasper"/>
       </delete>
       <echo level="info" message="Existing Jasper-Files deleted."/>
   </target>
   <target name="compile-jasper-templates" depends="init">
       <path id="jrc.classpath">
           <pathelement path="${build.classes.dir}"/>
           <fileset dir="./lib" includes="*.jar"/>
       </path>
       <property name="jasper.dir" value="${src}"/>
       <delete>
           <fileset dir="${jasper.dir}" includes="**/*.bak"/>
       </delete>
       <echo level="info" message="Existing Jasper-Backup-Files deleted."/>
       <taskdef name="jrc" classname="net.sf.jasperreports.ant.JRAntCompileTask">
           <classpath refid="jrc.classpath"/>
       </taskdef>
       <jrc srcdir="${jasper.dir}"
           tempdir="${jasper.dir}"
           destdir="${jasper.dir}">
           <classpath refid="jrc.classpath"/>
           <include name="**/*.jrxml"/>
       </jrc>
       <copy todir="${build.classes.dir}">
           <fileset dir="${src}"/>
       </copy>
       <echo level="info" message="Compilation of jasper-Templates completed."/>
   </target>

The first target deletes all .jasper files - you might add this target to your project's "clean" target. The second target compiles all .jrxml files and deletes any existing .bak files.

You might have to adjust some of the parameters, but this should be pretty much self-explaining...

Then, make sure your project's classpath contains the following jar files:

  • commons-beanutils.jar
  • commons-collections.jar
  • commons-digester.jar
  • commons-logging.jar
  • jasperreports.jar

The versions from the ADempiere project should work fine, I think - however, we're currently trying jasperreports-3.5.1.jar ;-)

Now, compilation of one or fifty or five hundred Jasper templates is just a few mouse clicks away.