<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.   
-->
<!-- ====================================================================== -->
<!--                                                                        -->
<!--     Ant build script to build/package JSE version of OpenBooks         -->
<!--                                                                        -->
<!-- ====================================================================== -->
                    
<project name="OpenBooks.JSE" default="package">
	
	<target name="package"
		description="Build, package and deploy OpenBooks as a Swing-based JSE application">
		<delete file="${target.dir}/openbooks.jar" failonerror="false"/>
		<delete file="${target.dir}/openbooks.zip" failonerror="false"/>
		
		<jar destfile="${target.dir}/openbooks.jar" basedir="${classes.dir}">
			<exclude name="junit/**" />
		</jar>
		<jar destfile="${target.dir}/openbooks.jar"
		     basedir="${rsrc.dir}"
		     update="true">
			<include name="images/*" />
		</jar>
        <!-- ASF released jars must include License and Notice files -->
		<jar destfile="${target.dir}/openbooks.jar"
		     basedir="${basedir}"
		     update="true">
			<include name="NOTICE.txt"/>
			<include name="LICENSE.txt"/>
		</jar>

		<delete dir="${deploy.dir}" failonerror="false"/>
		<mkdir dir="${deploy.dir}"/>
		<copy todir="${deploy.dir}">
			<fileset dir="${basedir}">
				<include name="run.properties" />
				<include name="run.xml" />
				<include name="index.html" />
				<include name="NOTICE.txt"/>
				<include name="LICENSE.txt"/>
			</fileset>
			<fileset dir="${target.dir}">
				<include name="openbooks.jar"/>
			</fileset>
			<fileset dir="${rsrc.dir}">
				<include name="load.properties" />
				<include name="demo.properties" />
				<include name="META-INF/persistence.xml" />
				<include name="slides/**" />
			</fileset>
		</copy>
		<mkdir dir="${deploy.dir}/source"/>
		<copy todir="${deploy.dir}/source">
			<fileset dir="${generated.html.dir}">
				<include name="**/*.css"/>
				<include name="**/*.html"/>
			</fileset>
		</copy>

	</target>
	
	<target name="compile" 
		description="Compile classes.">
		<javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true">
			<classpath refid="compile.classpath" />
			<exclude name="openbook/tools/**/*.java"/>
		</javac>
	</target>
	
	<target name="generate-source-with-options">
		<java2html 
			sourcepath="${src.dir}" 
			destDir="${generated.html.dir}" 
			extension=".html"
			addLineBreak="true"
			addExplicitSpace="true"
			verbose="false">
			<exclude name="openbook/tools/**/*.java"/>
			<exclude name="jpa/**/*.java"/>
			<exclude name="openbook/util/*.java"/>
		</java2html>
		<java2html 
			sourcepath="${generated.src.dir}" 
			destDir="${generated.html.dir}" 
			extension=".html"
			addLineBreak="true"
			addExplicitSpace="true"
			verbose="false">
		</java2html>
	</target>

</project>
