Java Reference
In-Depth Information
We can invoke the new target from the command line as follows:
ant viewDesign
After invoking the target, we should see a window very similar to the one we saw
when previewing the JRXML template.
Compiling a JRXML Template through ANT
JasperReports includes a custom ANT task that can be used to compile report
templates. Since we don't have to write code to perform the compilation, compiling
reports in this manner is very convenient. However, for certain applications we need
to compile a report programmatically, for example, in situations where the JRXML
file is created at run time. The custom ANT task included by JasperReports is called
JRC. It is defined in the net.sf.jasperreports.ant.JRAntCompileTask class. Let
us add a third target to our build.xml file to invoke the JRC task.
<project name="FirstReport XML Design Preview" default="viewDesignXML"
<description>Previews and compiles our First Report</description>
<property name="" value="FirstReport"/>
<!-- Directory where the JasperReports project file was extracted,
needs to be changed to match the local environment -->
<property name="jasper.dir"
<property name="classes.dir" value="${jasper.dir}/build/classes"/>
<property name="lib.dir" value="${jasper.dir}/lib"/>
<path id="classpath">
<pathelement location="./"/>
<pathelement location="${classes.dir}"/>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<target name="viewDesignXML"
description="Launches the design viewer to preview the XML
report design.">
<java classname="net.sf.jasperreports.view.JasperDesignViewer"
<arg value="-XML"/>
<arg value="-F${}.jrxml"/>
<classpath refid="classpath"/>
Search WWH ::

Custom Search