build.xml
author František Kučera <franta-hg@frantovo.cz>
Sun, 08 Jan 2012 17:26:24 +0100
changeset 78 7e478bfa5694
parent 64 c069af21c4be
child 82 90a58fca78e5
permissions -rw-r--r--
Definice uživatelských maker nebudeme kopírovat do výstupu, drobnosti.

<?xml version="1.0" encoding="UTF-8"?>
<!--
XML Web generátor – program na generování webových stránek
Copyright © 2012 František Kučera (frantovo.cz)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
<project name="xhtml-web" basedir="." default="generuj">

	<!-- Používané adresáře – např. zde můžete vstup a výstup nasměrovat do jiného verzovaného úložiště -->
	<property name="vstup" value="vstup"/>
	<property name="výstup" value="výstup"/>
	<property name="šablona" value="šablona"/>
	<property name="seznamMaker" value="${šablona}/.makra-seznam.xsl"/>
	<property name="temp" value="temp"/>
	<property name="funkce" value="${šablona}/funkce/build/classes"/>
	<property name="čára" value="----------------------------------------------------------------"/>
	
	<property name="vstupníPřípona" value=".xml"/>
	<property name="výstupníPřípona" value=".xhtml"/>
	
	<target	name="generuj" description="Vygeneruje kompletní web." depends="licence,agregace,stránky">
	</target>
	
	<target name="stránky" description="Vygeneruje samotné XHTML webové stránky." depends="statický-obsah,syntaxe,kompiluj-funkce,makra">		
		<xslt basedir="${vstup}" destdir="${výstup}" includes="*${vstupníPřípona}" extension="${výstupníPřípona}" style="${šablona}/stránka.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">
			<param name="podporaZaostalýchProhlížečů" expression="false"/>
			<param name="vstupníPřípona" expression="${vstupníPřípona}"/>
			<param name="výstupníPřípona" expression="${výstupníPřípona}"/>
			<classpath location="/usr/share/java/saxonb-9.0.jar"/>
			<classpath location="${funkce}"/>
			<factory name="net.sf.saxon.TransformerFactoryImpl">
				<attribute name="http://saxon.sf.net/feature/allow-external-functions" value="true"/>				
			</factory>
		</xslt>
	</target>
	
	<target name="syntaxe" description="Vygeneruje CSS styl pro zvýrazňování syntaxe" depends="kompiluj-funkce">
		<xslt in="${vstup}/web.conf" out="${výstup}/css/syntaxe.css" style="${šablona}/syntaxe.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">
			<classpath location="/usr/share/java/saxonb-9.0.jar"/>
			<classpath location="${funkce}"/>
			<factory name="net.sf.saxon.TransformerFactoryImpl">
				<attribute name="http://saxon.sf.net/feature/allow-external-functions" value="true"/>				
			</factory>
		</xslt>
	</target>
	
	<target name="makra" description="Vygeneruje seznam maker podle souborů v příslušných složkách" depends="kompiluj-funkce">
		<xslt in="${vstup}/web.conf" out="${seznamMaker}" style="${šablona}/makra.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">
			<classpath location="/usr/share/java/saxonb-9.0.jar"/>
			<classpath location="${funkce}"/>
			<factory name="net.sf.saxon.TransformerFactoryImpl">
				<attribute name="http://saxon.sf.net/feature/allow-external-functions" value="true"/>				
			</factory>
		</xslt>
	</target>
	
	<target name="agregace" description="Vytvoří agregované výstupy: RSS, Atom, Sitemap.xml." depends="kompiluj-funkce">
		<!-- TODO: sloučit, zjednodušit, parametrizovat -->
	
		<!-- Atom -->
		<xslt in="${vstup}/web.conf" out="${výstup}/atom.xml" style="${šablona}/atom.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">
			<param name="vstupníPřípona" expression="${vstupníPřípona}"/>
			<param name="výstupníPřípona" expression="${výstupníPřípona}"/>
			<classpath location="/usr/share/java/saxonb-9.0.jar"/>
			<classpath location="${funkce}"/>
			<factory name="net.sf.saxon.TransformerFactoryImpl">
				<attribute name="http://saxon.sf.net/feature/allow-external-functions" value="true"/>				
			</factory>
		</xslt>
		
		<!-- RSS --> 
		<xslt in="${výstup}/atom.xml" out="${výstup}/rss.xml" style="${šablona}/rss.xsl"  processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">			
			<classpath location="/usr/share/java/saxonb-9.0.jar"/>
			<classpath location="${funkce}"/>
			<factory name="net.sf.saxon.TransformerFactoryImpl">
				<attribute name="http://saxon.sf.net/feature/allow-external-functions" value="true"/>				
			</factory>
		</xslt>
		
		<!-- Sitemap.xml -->
		<xslt in="${výstup}/atom.xml" out="${výstup}/sitemap.xml" style="${šablona}/sitemap.xsl"  processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">			
			<classpath location="/usr/share/java/saxonb-9.0.jar"/>
			<classpath location="${funkce}"/>
			<factory name="net.sf.saxon.TransformerFactoryImpl">
				<attribute name="http://saxon.sf.net/feature/allow-external-functions" value="true"/>				
			</factory>
		</xslt>
		
		<!-- Seznam stránek --> 
		<xslt in="${výstup}/atom.xml" out="${vstup}/.seznam.xml" style="${šablona}/seznam.xsl"  processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">			
			<classpath location="/usr/share/java/saxonb-9.0.jar"/>
			<classpath location="${funkce}"/>
			<factory name="net.sf.saxon.TransformerFactoryImpl">
				<attribute name="http://saxon.sf.net/feature/allow-external-functions" value="true"/>				
			</factory>
		</xslt>
		
	</target>
	
	<target name="kompiluj-funkce" description="Přeloží funkce napsané v Javě.">		
		<mkdir dir="${funkce}"/>
		<javac
			srcdir="${šablona}/funkce/src"
			destdir="${funkce}"			
			includeAntRuntime="no">
		</javac>
	</target>
	
	<target name="statický-obsah" description="Kopíruje JS, CSS, obrázky atd.">
		<copy todir="${výstup}">
			<fileset dir="${vstup}" excludes="*.xml,makra/**,*.inc,web.conf"/>
		</copy>
	</target>
	
	<target name="čisti" description="Smaže vygenerovaný obsah.">
		<delete includeemptydirs="true">
			<fileset dir="${výstup}" includes="**/*"/>
			<fileset dir="${funkce}" includes="**/*"/>
			<fileset file="${seznamMaker}"/>
		</delete>
	</target>
	
	<target name="prohlédni" description="Otevře vygenerované stránky ve www prohlížeči.">
		<exec executable="x-www-browser" os="Linux">
			<arg value="${výstup}/index${výstupníPřípona}"/>
		</exec>
	</target>
	
	<target name="licence">
		<echo>${čára}
XML Web generátor Copyright © 2012 František Kučera (frantovo.cz)
This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions; type ‚ant licence-gpl‘ for details.
${čára}</echo>
	</target>
	
	<target name="licence-gpl">
		<loadfile property="licence.txt" srcFile="licence/licence.txt"/>
		<loadfile property="gpl-3.0.txt" srcFile="licence/gpl-3.0.txt"/>
		<echo>${čára}</echo> 
		<echo>${licence.txt}</echo> 
		<echo>${čára}</echo> 
		<echo>${gpl-3.0.txt}</echo> 
		<echo>${čára}</echo> 
	</target>
	
</project>