<?xml version="1.0" encoding="UTF-8"?>

<project name="paraselene" default="build" basedir=".">
	<property name="src.dir" value="paraselene"/>
	<property name="class.dir" value="classes"/>
	<property name="jar.dir" value="bin"/>
	<property name="api.dir" value="api"/>
	<loadfile property="ver" srcFile="Version.txt">
		<filterchain>
			<striplinebreaks/>
		</filterchain>
	</loadfile>
	<property name="tar.dir" value="paraselene-${ver}"/>
	<property name="jar.name" value="${tar.dir}.jar"/>
	<property name="jar.crt" value="paraselene.jar"/>
	<property name="release" value="${jar.dir}/${tar.dir}.src.tar.gz"/>
	<property name="auth" value="Akira Terasaki"/>

	<target name="build">
		<mkdir dir="${class.dir}"/>
		<mkdir dir="${jar.dir}"/>
		<mkdir dir="${api.dir}"/>
		<delete file="${src.dir}/Version.java"/>
		<copy file="template/Version.java" tofile="${src.dir}/Version.java"/>
		<replace file="${src.dir}/Version.java" token="@@@ver" value="${ver}"/>
		<replace file="${src.dir}/Version.java" token="@@@auth" value="${auth}"/>
		<javac includeAntRuntime="no" srcdir="${src.dir}" destdir="${class.dir}" sourcepath="" debug="on">
			<include name="**/*.java"/>
			<compilerarg value="-Xlint:unchecked" />
		</javac>

		<exec executable="tool/script.sh"/>
		<delete file="${release}"/>
		<delete dir="${tar.dir}"/>
		<mkdir dir="${tar.dir}"/>
		<exec executable="cp">
			<arg line="-pr Copyright.txt License.txt Version.txt build.xml paraselene template output_sample readme tool resource ${tar.dir}"/>
		</exec>
		<exec executable="tar">
			<arg line="zcvf ${release} ${tar.dir}"/>
		</exec>
		<delete dir="${tar.dir}"/>

		<copy file="Copyright.txt" tofile="${class.dir}/Copyright.txt"/>
		<copy file="License.txt" tofile="${class.dir}/License.txt"/>
		<copy file="Version.txt" tofile="${class.dir}/Version.txt"/>
		<delete file="${jar.dir}/${jar.name}"/>
		<jar destfile="${jar.dir}/${jar.name}" basedir="${class.dir}" index="true">
			<fileset dir="resource" />
			<manifest>
				<attribute name="Extension-Name" value="paraselene"/>
				<attribute name="Specification-Title" value="Paraselene Web Framework"/>
				<attribute name="Specification-Version" value="${ver}"/>
				<attribute name="Specification-Vendor" value="${auth}"/>
				<attribute name="Implementation-Title" value="paraselene"/>
				<attribute name="Implementation-Version" value="${ver}"/>
				<attribute name="Implementation-Vendor" value="${auth}"/>
			</manifest>
		</jar>
		<exec executable="ln" dir="${jar.dir}">
			<arg line="-fs ${jar.name} ${jar.crt}"/>
		</exec>

		<javadoc destdir="${api.dir}" use="true" encoding="UTF-8" charset="UTF-8"
			windowtitle="Paraselene ${ver} API" Overview="template/overview.html">
			<doctitle>Paraselene ${ver} API 仕様</doctitle>
			<fileset dir=".">
				<include name="paraselene/**"/>
				<exclude name="paraselene/mockup/**"/>
				<exclude name="paraselene/ajax/data/**"/>
				<exclude name="paraselene/tool/**"/>
			</fileset>
			<group title="基本機能" packages="paraselene:paraselene.supervisor"/>
			<group title="HTMLタグ制御" packages="paraselene.tag:paraselene.tag.*"/>
			<group title="オプション機能" packages="paraselene.ajax:paraselene.css:paraselene.dyna:paraselene.dyna.mockup:paraselene.ui"/>
			<group title="ユニットテスト" packages="paraselene.test"/>
			<link href="http://java.sun.com/javase/ja/6/docs/ja/api/"/>
			<link href="http://java.sun.com/javaee/6/docs/api/"/>
		</javadoc>
	</target>

	<target name="clean">
		<delete dir="${class.dir}"/>
		<delete dir="${jar.dir}"/>
		<delete dir="${api.dir}"/>
	</target>
</project>

