<project name="openflashchart" default="javac" basedir=".">

	<description>Shows how Open Flash Charts could be included in HTML and PDF reports using a specially designed component.</description>

	<property name="class.name" value="OFCApp" />
	<property name="base.file.name" value="OpenFlashChartReport" />
	<property name="file.name" value="${basedir}/build/${base.file.name}" />
	<property name="classes.dir" value="../../../build/classes" />
	<property name="lib.dir" value="../../../lib" />
	<property name="fonts.dir" value="../../fonts" />
	<property name="web.dir" value="./build/web"/>
	
	<path id="classpath">
		<pathelement location="./build/classes"/>
		<pathelement location="./build/component"/>
		<fileset dir="./lib">
			<include name="**/*.jar"/>
		</fileset>
		<pathelement location="${classes.dir}" />
		<pathelement location="${fonts.dir}" />
		<fileset dir="${lib.dir}">
			<include name="**/*.jar"/>
		</fileset>
		<!-- PDF export needs SWF file -->
		<pathelement location="./web"/>
	</path>

	<target name="javac" description="Compiles the java source files of the test application.">
		<mkdir dir="./build/classes"/> 
		<javac srcdir="." destdir="./build/classes" debug="true" optimize="false" deprecation="false">
			<classpath refid="classpath"/>
			<include name="*.java"/>
		</javac>
		<mkdir dir="./build/component"/> 
		<javac srcdir="./src" destdir="./build/component" debug="true" optimize="false" deprecation="false" source="1.5" target="1.5">
			<classpath refid="classpath"/>
		</javac>
		<copy todir="./build/component">
			<fileset dir="./src">
				<exclude name="**/*.java"/>
			</fileset>
		</copy>
	</target>
	
	<target name="jar" description="Packs the component classes and resources into a jar" depends="javac">
		<jar jarfile="./build/jasperreports-ofc.jar">
			<manifest>
				<attribute name="Built-By" value="Jaspersoft"/>
			</manifest>		
			<fileset dir="./build/component"/>
		</jar>
	</target>

	<target name="compile" description="Compiles the XML report design and produces the .jasper file.">
		<mkdir dir="./build"/> 
		<taskdef name="jrc" classname="net.sf.jasperreports.ant.JRAntCompileTask"> 
			<classpath refid="classpath"/>
		</taskdef>
		<jrc destdir="./build">
			<src>
				<fileset dir=".">
					<include name="*.jrxml"/>
				</fileset>
			</src>
			<classpath refid="classpath"/>
		</jrc> 
	</target>

	<target name="fill" description="Fills the compiled report design with data and produces the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="fill"/>
			<arg value="${file.name}.jasper"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="view" description="Launches the report viewer to preview the report stored in the .jrprint file.">
		<java classname="net.sf.jasperreports.view.JasperViewer" fork="true">
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="viewXml" description="Launches the report viewer to preview the generated report stored in an XML file.">
		<java classname="net.sf.jasperreports.view.JasperViewer" fork="true">
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="print" description="Sends the report in the .jrprint file to the printer.">
		<java classname="${class.name}" fork="true">
			<arg value="print"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="pdf" description="Generates an PDF  version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="pdf"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="xml" description="Generates an XML version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="xml"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="xmlEmbed" description="Generates an XML version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="xmlEmbed"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="html" description="Generates an HTML version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="html"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="rtf" description="Generates an RTF version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="rtf"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="xls" description="Generates an XLS version of the report by converting the .jrprint file using the POI library.">
		<java classname="${class.name}" fork="true">
			<arg value="xls"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="jxl" description="Generates an XLS version of the report by converting the .jrprint file using the JExcelApi library.">
		<java classname="${class.name}" fork="true">
			<arg value="jxl"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="csv" description="Generates a CSV version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="csv"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="odt" description="Generates an ODT version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="odt"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="ods" description="Generates an ODS version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="ods"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="docx" description="Generates a DOCX version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="docx"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="xlsx" description="Generates an XLSX version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="xlsx"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="pptx" description="Generates a PPTX version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="pptx"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="xhtml" description="Generates an XHTML version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="xhtml"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="xml4swf" description="Generates an Xml4Swf version of the report by converting the .jrprint file.">
		<java classname="${class.name}" fork="true">
			<arg value="xml4swf"/>
			<arg value="${file.name}.jrprint"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="viewHTML" description="Displays the HTML and XHTML reports by starting an embedded web server and launching a browser.">
		<mkdir dir="${web.dir}"/>
		<copy todir="${web.dir}">
			<fileset dir="./web"/>
			<fileset dir="./build">
				<include name="*.html"/>
				<include name="*.html_files/*"/>
			</fileset>
		</copy>
		<java classname="${class.name}" fork="true" dir="${web.dir}">
			<arg value="viewHTML"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="viewDesignXml" description="Launches the design viewer to preview the XML report design.">
		<java classname="net.sf.jasperreports.view.JasperDesignViewer" fork="true">
			<arg value="./${base.file.name}.jrxml"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="viewDesign" description="Launches the design viewer to preview the compiled report design.">
		<java classname="net.sf.jasperreports.view.JasperDesignViewer" fork="true">
			<arg value="${file.name}.jasper"/>
			<classpath refid="classpath"/>
		</java>
	</target>

	<target name="clean" description="Deletes all the generated files.">
		<delete dir="./build" />
	</target>

	<target name="test" description="Runs the sample.">
		<echo message="==================================="/>
		<echo message=" Open Flash Chart Component Sample"/>
		<echo message="==================================="/>
		<antcall target="clean" />
		<antcall target="javac" />
		<antcall target="compile" />
		<antcall target="fill" />
		<antcall target="pdf" />
		<antcall target="xmlEmbed" />
		<antcall target="xml" />
		<antcall target="html" />
		<antcall target="rtf" />
		<antcall target="xls" />
		<antcall target="jxl" />
		<antcall target="csv" />
		<antcall target="odt" />
		<antcall target="ods" />
		<antcall target="docx" />
		<antcall target="xlsx" />
		<antcall target="pptx" />
		<antcall target="xhtml" />
		<antcall target="xml4swf" />
	</target>
	
</project>
