1<!-- 2// This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 3// 4// TagSoup is licensed under the Apache License, 5// Version 2.0. You may obtain a copy of this license at 6// http://www.apache.org/licenses/LICENSE-2.0 . You may also have 7// additional legal rights not granted by this license. 8// 9// TagSoup is distributed in the hope that it will be useful, but 10// unless required by applicable law or agreed to in writing, TagSoup 11// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 12// OF ANY KIND, either express or implied; not even the implied warranty 13// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14--> 15 16<project name="tagsoup" default="dist"> 17 18 <!-- generic properties --> 19 <property file="etc/build/build.properties"/> 20 <!-- additional tasks --> 21 <taskdef file="etc/build/taskdefs.txt" classpath="bin"/> 22 23 <available property="transformer.factory" 24 classname="com.icl.saxon.TransformerFactoryImpl" 25 value="com.icl.saxon.TransformerFactoryImpl"/> 26 <available property="transformer.factory" 27 classname="net.sf.saxon.TransformerFactoryImpl" 28 value="net.sf.saxon.TransformerFactoryImpl"/> 29 <available property="transformer.factory" 30 classname="org.apache.xalan.processor.TransformerFactoryImpl" 31 value="org.apache.xalan.processor.TransformerFactoryImpl"/> 32 <available property="transformer.factory" 33 classname="com.sun.org.apache.xalan.processor.TransformerFactoryImpl" 34 value="com.sun.org.apache.xalan.processor.TransformerFactoryImpl"/> 35 36 <!-- some folder settings --> 37 <property name="bin" value="bin"/> 38 <property name="src" value="src"/> 39 <property name="build" value="build"/> 40 <property name="dist" value="dist"/> 41 <property name="docs" value="docs"/> 42 <property name="tmp" value="tmp"/> 43 44 45 <!-- initialize project --> 46 <target name="init" description="Init project."> 47 <tstamp/> 48 </target> 49 50 51 <!-- ensure needed folders are available --> 52 <target name="prepare" description="Set up folders."> 53 <mkdir dir="${build}"/> 54 <mkdir dir="${tmp}"/> 55 </target> 56 57 <!-- Build a distribution jar file --> 58 <target name="dist" depends="init,compile" 59 description="Build a binary distribution file."> 60 <antcall target="jar-release"> 61 <param name="buildDir" value="build"/> 62 <param name="version" value="${tagsoup.version}"/> 63 </antcall> 64 </target> 65 66 67 <target name="jar-release" depends="init" 68 description="Build a release jar file."> 69 <mkdir dir="${dist}/lib" /> 70 <jar jarfile="${dist}/lib/tagsoup-${tagsoup.version}.jar" basedir="${buildDir}"> 71 <manifest> 72 <attribute name="Version" value="${tagsoup.version}"/> 73 <attribute name="Main-Class" value="org.ccil.cowan.tagsoup.CommandLine"/> 74 </manifest> 75 </jar> 76 </target> 77 78 79 <!-- compile java sources --> 80 <target name="compile" depends="init,prepare,build-parser" 81 description="Compile java classes."> 82 <javac source="1.4" target="1.4" srcdir="${src}/java" destdir="${build}" deprecation="on" verbose="off" debug="on"> 83 <src path="${src}/java"/> 84 <src path="${tmp}/src"/> 85 </javac> 86 </target> 87 88<!-- prepare generation of the parser classes based on the definition files --> 89 <target depends="init,prepare" description="Prepare generation of parser classes." name="prepare-parser"> 90 91 <echo> 92 Using ${transformer.factory} as the TransformerFactory 93 </echo> 94 95 <xslt in="${src}/definitions/html.tssl" out="${tmp}/HTMLModels.i" 96style="tssl/tssl-models.xslt"> 97 <factory name="${transformer.factory}"/> 98 </xslt> 99 <xslt in="${src}/definitions/html.tssl" out="${tmp}/HTMLSchema.i" 100style="tssl/tssl.xslt"> 101 <factory name="${transformer.factory}"/> 102 </xslt> 103 <xslt in="${src}/definitions/html.stml" out="${tmp}/HTMLScanner.i" 104style="stml/stml.xslt"> 105 <factory name="${transformer.factory}"/> 106 </xslt> 107 </target> 108 109 110 111 <!-- patch the parser class files --> 112 <target name="build-parser" depends="prepare-parser" 113 description="Generate parser class files."> 114 <property name="parser.pkg-path" value="org/ccil/cowan/tagsoup"/> 115 <mkdir dir="${tmp}/src/${parser.pkg-path}"/> 116 <antcall target="patch-file"> 117 <param name="file-pref" value="HTMLModels"/> 118 <param name="token" value="MODEL_DEFINITIONS"/> 119 </antcall> 120 <antcall target="patch-file"> 121 <param name="file-pref" value="HTMLSchema"/> 122 <param name="token" value="SCHEMA_CALLS"/> 123 </antcall> 124 <antcall target="patch-file"> 125 <param name="file-pref" value="HTMLScanner"/> 126 <param name="token" value="STATE_TABLE"/> 127 </antcall> 128 </target> 129 130 131 <!-- patch one parser class file --> 132 <target name="patch-file" depends="" description="Patch a parser class file."> 133 <copy file="${src}/templates/${parser.pkg-path}/${file-pref}.java" toDir="${tmp}/src/${parser.pkg-path}"/> 134 <loadfile property="patch" srcFile="${tmp}/${file-pref}.i"/> 135 <replace file="${tmp}/src/${parser.pkg-path}/${file-pref}.java" token="@@${token}@@" value="${patch}"/> 136 </target> 137 138 <!-- clean up the mess --> 139 <target name="clean" description="Clean up folders."> 140 <delete dir="${build}"/> 141 <delete dir="${tmp}"/> 142 <delete dir="${docs}"/> 143 <delete dir="${dist}"/> 144 </target> 145 146 147 <!-- generate javadoc for the java classes --> 148 <target name="docs-api" depends="init" 149 description="Generate javadoc documentation."> 150 <mkdir dir="${docs}/api"/> 151 <javadoc packagenames="org.*" 152 sourcepath="${src}/java" destdir="${docs}/api" 153 use="true" 154 windowtitle="TagSoup ${tagsoup.version} API"> 155 <doctitle><![CDATA[<h1>TagSoup Package Documentation</h1>]]></doctitle> 156 <bottom><![CDATA[<em>Licence</em>: <strong>Academic Free License 3.0</strong> and/or <strong>GPL 2.0</strong>]]></bottom> 157 </javadoc> 158 </target> 159 160</project> 161