Source

docbook-xsl-ufrgs-eco-tcc / build.xml

Full commit
<?xml version="1.0" encoding="windows-1252" ?>
<project name="docbook-xsl-ufrgs-eco-tcc" basedir="." default="run-proc-fop">
	
	<property file="build.properties"/>

	<!-- defina neste arquivo as properties específicas de seu projeto -->
	<property file="local.properties" />
	
	<property name="src_java" value="${basedir}/src_java"/>
	<property name="bin" value="${basedir}/bin"/>
	<property name="build" value="${basedir}/build"/>
	<property name="dist" value="${basedir}/dist"/>
	<property name="xsl.dir" value="${basedir}/xsl"/>
	<property name="srcfiles.dir" value="${basedir}/test_docbook"/>

	<!-- fop properties -->
	<property name="file.xmlinput" value="${srcfiles.dir}/docbook-tcc-input.xml"/>
	<property name="csv-tables-dir" value="${srcfiles.dir}/tables-csv"/>
	<property name="file.xsl" value="${srcfiles.dir}/docbook-tcc-input.xsl"/>
	<!-- property name="file-epub.xsl" value="${srcfiles.dir}/docbook-tcc-input-epub.xsl"/ --> <!-- not used... -->
	<property name="file.pdfoutput" value="${dist}/tcc-output.pdf"/>
	<property name="file.rtfoutput" value="${dist}/tcc-output.rtf"/>
	<property name="file.epub.builddir" value="${build}/epub"/>
	<property name="file.epub.output" value="${dist}/tcc-output.epub"/>

	<!-- xsl template properties -->
	<property name="file-template.xmlinput" value="${xsl.dir}/tcc-eco-template.xml"/>
	<property name="file-template.output" value="${build}/tcc-eco-template-out.xsl"/>
	<property name="file-template.xsl" value="${docbook-xsl-dir}/template/titlepage.xsl"/>

	<path id="foppath">
		<pathelement location="${xalan-dir}/xalan.jar"/> <!-- using xalan 2.7.1 -->
		<pathelement location="${fop-dir}/build/fop.jar"/>
		<pathelement location="${fop-dir}/lib/avalon-framework-4.2.0.jar"/>
		<pathelement location="${fop-dir}/lib/batik-all-1.7.jar"/>
		<pathelement location="${fop-dir}/lib/commons-io-1.3.1.jar"/>
		<pathelement location="${fop-dir}/lib/xmlgraphics-commons-1.4.jar"/>
		<!--pathelement location="${fop-dir}/lib/jai_core.jar"/>
		<pathelement location="${fop-dir}/lib/jai_codec.jar"/-->
		<pathelement location="${fop-dir}/lib/batik-all-1.7.jar"/>
		<pathelement location="${fop-dir}/lib/commons-logging-1.0.4.jar"/>
		<pathelement location="${fop-dir}/lib/xml-apis-ext-1.3.04.jar"/>
		<pathelement location="${xml-commons-resolver-dir}/resolver.jar"/>
		<!--pathelement location="${xalan-dir}/serializer.jar"/>
		<pathelement location="${xalan-dir}/xalan.jar"/>
		<pathelement location="${xalan-dir}/xercesImpl.jar"/>
		<pathelement location="${xalan-dir}/xml-apis.jar"/-->
		<!--pathelement location="${lib_xtra}/log4j-1.2.15.jar"/-->
		<pathelement location="${bin}"/>
	</path>

	<path id="localpath">
		<pathelement location="${bin}"/>
	</path>

	<path id="xsltpath">
		<pathelement location="${xalan-dir}/xalan.jar"/> <!-- using xalan 2.7.1 -->
		<pathelement location="${xalan-dir}/serializer.jar"/>
		<pathelement location="${xalan-dir}/xercesImpl.jar"/>
		<pathelement location="${xalan-dir}/xml-apis.jar"/>
		<pathelement location="${fop-dir}/build/fop.jar"/>
		<pathelement location="${fop-dir}/lib/avalon-framework-4.2.0.jar"/>
		<pathelement location="${fop-dir}/lib/batik-all-1.7.jar"/>
		<pathelement location="${fop-dir}/lib/commons-io-1.3.1.jar"/>
		<pathelement location="${fop-dir}/lib/xmlgraphics-commons-1.4.jar"/>
		<!--pathelement location="${fop-dir}/lib/jai_core.jar"/>
		<pathelement location="${fop-dir}/lib/jai_codec.jar"/-->
		<pathelement location="${fop-dir}/lib/batik-all-1.7.jar"/>
		<pathelement location="${fop-dir}/lib/commons-logging-1.0.4.jar"/>
		<pathelement location="${fop-dir}/lib/xml-apis-ext-1.3.04.jar"/>
		<pathelement location="${xml-commons-resolver-dir}/resolver.jar"/>
		<!--pathelement location="${lib_xtra}/log4j-1.2.15.jar"/-->
		<pathelement location="${bin}"/>
	</path>
	
	<path id="epubcheckpath">
		<pathelement location="${epubcheck-dir}/epubcheck-1.2.jar"/>
	</path>
	
	<target name="prepare">
		<mkdir dir="${bin}"/>
		<mkdir dir="${build}"/>
		<mkdir dir="${dist}"/>
	</target>	
		
	<target name="run-proc-fop" depends="prepare">
		<java classname="org.apache.fop.cli.Main" classpathref="foppath" fork="true">
		    <!--jvmarg value="-Dlog4j.configuration=file:src_resolver/log4j.properties"/-->
		    <arg value="-catalog"/>
		    <arg value="-xml"/>
		    <arg value="${file.xmlinput}"/>
		    <arg value="-xsl"/>
		    <arg value="${file.xsl}"/>
		    <arg value="-pdf"/>
		    <arg value="${file.pdfoutput}"/>
		</java>
	</target>

	<!--
	(test) target for FOP processing in java 
	-->
	<target name="run-proc-fop-test" depends="prepare">
		<java classname="tbrugz.fop.FOP_Proc" classpathref="foppath" fork="true" dir="${srcfiles.dir}">
		    <arg value="${file.xmlinput}"/>
		    <arg value="${file.xsl}"/>
		    <arg value="${file.pdfoutput}"/>
		</java>
	</target>
	
	<target name="run-proc-epub" depends="prepare">
		<!--
		ver:
		http://www.ibm.com/developerworks/xml/tutorials/x-epubtut/section5.html
		http://en.wikipedia.org/wiki/EPUB
		http://inasmuch.as/2010/12/10/ant-for-epub/
		-->
		<delete dir="${file.epub.builddir}"/>
		<mkdir dir="${file.epub.builddir}"/>
		<copy file="${xsl.dir}/mimetype.epub" tofile="${file.epub.builddir}/mimetype" />
		<java classname="org.apache.xalan.xslt.Process" classpathref="foppath" fork="true">
		    <arg value="-in"/>
		    <arg value="${file.xmlinput}"/>
		    <arg value="-xsl"/>
		    <arg value="${docbook-xsl-dir}/epub/docbook.xsl"/>
		    <arg value="-out"/>
		    <arg value="${file.epub.builddir}/tcc-output-epub.xml"/>
		</java>
		<!--mkdir dir="${file.epub.builddir}/OEBPS/"/-->
		<!--mkdir dir="${file.epub.builddir}/OEBPS/figures/"/-->
		<!--copy todir="${file.epub.builddir}/OEBPS/figures/">
			<fileset dir="${srcfiles.dir}/figures/" includes="*.png, *.jpg"/>
		</copy-->
		<!--copy todir="${file.epub.builddir}/META-INF/">
			<fileset dir="${srcfiles.dir}/epub" includes="*.xml"/>
		</copy-->
		<!--copy todir="${file.epub.builddir}/OEBPS/covers/">
			<fileset dir="${srcfiles.dir}/covers/" includes="*.png, *.jpg"/>
		</copy-->
		<copy todir="${file.epub.builddir}/OEBPS/">
			<fileset dir="${srcfiles.dir}/" includes="**/*.png, **/*.jpg"/>
		</copy>

		<delete file="${file.epub.output}" />

		<echo message="temp zip n. 1..."/>
		<zip destfile="${file.epub.output}.mime.zip" basedir="${file.epub.builddir}" includes="mimetype" defaultexcludes="true" compress="false"/>

		<echo message="temp zip n. 2..."/>
		<zip destfile="${file.epub.output}.rest.zip" basedir="${file.epub.builddir}" update="true" duplicate="preserve" excludes="tcc-output-epub.xml,mimetype"/>
		
		<zip destfile="${file.epub.output}"
			update="true"
			keepcompression="true"
			encoding="UTF-8">
			<zipfileset src="${file.epub.output}.mime.zip" />
			<zipfileset src="${file.epub.output}.rest.zip" />
		</zip>
		
		<!-- Delete the temporary Zip files. -->
		<delete file="${file.epub.output}.mime.zip" />
		<delete file="${file.epub.output}.rest.zip" />		
		
		<!-- check generated epub -->
		<java jar="${epubcheck-dir}/epubcheck-1.2.jar" classpathref="epubcheckpath" fork="true">
		    <arg value="${file.epub.output}"/>
		</java>
	</target>
	
	<target name="run-proc-fop-rtf" depends="prepare">
		<java classname="org.apache.fop.cli.Main" classpathref="foppath" fork="true">
		    <arg value="-catalog"/>
		    <arg value="-xml"/>
		    <arg value="${file.xmlinput}"/>
		    <arg value="-xsl"/>
		    <arg value="${file.xsl}"/>
		    <arg value="-rtf"/>
		    <arg value="${file.rtfoutput}"/>
		</java>
	</target>
	
	<target name="check-template-uptodate">
		<uptodate targetfile="${file-template.output}" srcfile="${file-template.xmlinput}" property="template.is.newer"/>
	</target>
	
	<!--
	http://xml.apache.org/xalan-j/getstarted.html
	java -Duser.language=en -Duser.region=US org.apache.xalan.xslt.Process -in tcc-eco/tcc-eco-template.xml -xsl docbook-xsl-1.76.1-RC1/template/titlepage.xsl -out tcc-eco/tcc-eco-template-out.xsl
	-->
	<target name="run-proc-xsl-template" depends="prepare, check-template-uptodate" unless="template.is.newer">
		<echo message="running..."/>
		<java classname="org.apache.xalan.xslt.Process" classpathref="xsltpath" fork="true">
		    <arg value="-in"/>
		    <arg value="${file-template.xmlinput}"/>
		    <arg value="-xsl"/>
		    <arg value="${file-template.xsl}"/>
		    <arg value="-out"/>
		    <arg value="${file-template.output}"/>
		</java>
		<echo message="runned"/>
	</target>

	<target name="run-env-check">
		<java classname="org.apache.xalan.xslt.EnvironmentCheck" classpathref="foppath" />
		<echo message="XML: ${file.xmlinput}" />
		<echo message="XSL: ${file.xsl}" />
		<echo message="out-PDF: ${file.pdfoutput}" />
		<echo message="out-RTF: ${file.rtfoutput}" />
		<echo message="out-EPUB: ${file.epub.output}" />
	</target>
	
	<target name="compile" depends="prepare">
		<copy todir="${bin}">
			<fileset dir="${src_java}" excludes="**/*.java"/>
		</copy>
		<javac srcdir="${src_java}" destdir="${bin}"/>
	</target>
	
	<target name="clean">
		<delete includeemptydirs="true">
			<fileset dir="${bin}"/>
			<fileset dir="${build}"/>
			<fileset dir="${dist}"/>
		</delete>
	</target>

	<target name="run-csv2docbooktable" depends="prepare">
		<java classname="tbrugz.docbook.CSV2DocbookTable" classpathref="localpath">
		    <arg value="-allfromdir"/>
		    <arg value="${csv-tables-dir}"/>
		    <arg value="${build}"/>
		</java>
	</target>
	
	<!-- apenas windows :( -->
	<target name="run-acroread">
		<exec executable="cmd">
		    <arg value="/c"/>
		    <arg value="start"/>
		    <arg value="acrord32"/>
		    <arg value="${file.pdfoutput}"/>
		</exec>
	</target>
	
	<target name="fop+acroread" depends="run-proc-xsl-template, run-proc-fop, run-acroread"/>

	<target name="build-all" depends="compile, run-proc-xsl-template, run-proc-fop-rtf, run-proc-fop, run-proc-epub"/>

	<target name="dtd-validate">
		<!--xmlvalidate failonerror="yes" lenient="no" warn="yes" file="${file.xmlinput}"-->
		<xmlvalidate lenient="no" warn="yes" file="${file.xmlinput}">
			<xmlcatalog></xmlcatalog>
			<dtd publicid="-//OASIS//DTD DocBook XML V4.5//EN" location="${docbook-xml-4.5}/docbookx.dtd"/>
			<attribute name="http://xml.org/sax/features/validation" value="true"/>
		</xmlvalidate>
	</target>
	
	<!--target name="run-test">
		<echo message="running..."/>
		<java classname="org.apache.xalan.xslt.Process" classpathref="foppath" fork="true">
		</java>
		<echo message="runned"/>
	</target-->
	
</project>