Jump to content
We've recently updated our Privacy Statement, available here ×

Command line compile of .jrxml?


clp

Recommended Posts

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I am not sure if this is what you are looking for but there is a way to use ant to compile jrxml files into jasper. I found how to do it looking at the samples included in the jasper reports download. I think I was using version 3.0.0 at the time but it should work for any if you have ant and the build.xml correct.

Link to comment
Share on other sites

I used the build.xml file and placed the .jrxml files in the reports folder, then used ant to build them. The build will create a new folder that contains your .jasper files. You can modify the files to include other files that will need to be deployed with the compiled reports such as image files .

I have tried to attach a copy of the folders I used but that must be too large to post correctlyso I will try this. I used jasperreports-2.0.4 along with the compile jar in one folder. Inside a second folder I placed the build.xml and a folder containing the .jrxml files. I will try to post the build.xml here. Then all you will need to have ant working on your machine.

Post Edited by David Seyb at 02/27/09 18:37



Post Edited by David Seyb at 02/27/09 18:42
Link to comment
Share on other sites

For some reason the attachment never seems to show up, so I will do this:

 

 

Code:
<project name="antcompile" default="compile1" basedir=".">	<description>Shows how multiple JRXML files can be compiled in batch mode using ANT.</description>	<path id="classpath">		<pathelement location="./build/classes"/>		<fileset dir="../lib">			<include name="**/*.jar"/>		</fileset>	</path>		<path id="runClasspath">		<path refid="classpath"/>		<pathelement location="./build/classes"/>	</path>	<taskdef name="jrc" classname="net.sf.jasperreports.ant.JRAntCompileTask"> 		<classpath refid="classpath"/>	</taskdef>		<target name="copy-resources">		<copy todir="./build/reports">			<fileset dir="./reports">				<exclude name="**/*.jrxml"/>			</fileset>		</copy>	</target>	<target name="javac" description="Compiles the Java source files used in the report designs.">		<mkdir dir="./build/classes"/> 		<javac srcdir="./src" destdir="./build/classes" debug="true" optimize="false" deprecation="false"/>	</target> 	<target name="compile1" depends="clean,copy-resources" description="Compiles report designs specified using the "srcdir" in the <jrc> tag. Generated .jasper files keep their relative location and are placed in directory structure similar to the source files structure."> 		<jrc 				srcdir="./reports"				destdir="./build/reports"				tempdir="./build/reports"				keepjava="false"				xmlvalidation="true">			<classpath refid="runClasspath"/>			<include name="**/*.jrxml"/>		</jrc>	</target> 	<target name="compile2" depends="clean,copy-resources" description="Compiles report designs specified using a <fileset> in the <src> tag. Generated .jasper files lose their relative location and are placed in the same output directory.">		<jrc 				destdir="./build/reports"				tempdir="./build/reports"				keepjava="false"				xmlvalidation="true">			<src>				<fileset dir="./reports">					<include name="**/*.jrxml"/>				</fileset>			</src>			<classpath refid="runClasspath"/>		</jrc> 	</target> 	<target name="clean" description="Deletes all the generated files.">		<delete dir="./build" />		<mkdir dir="./build/reports"/>	</target></project>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...