<?xml version="1.0"?>
<!-- ======================================================================
     2005/08/11 16:40:11

     terasoluna-thin.jarを生成するビルドファイル。
     ====================================================================== -->
<project name="terasoluna-thin" default="jar" basedir="..">
  <property file="./ant/build.properties" />
  <property name="lib.dir" value="${terasoluna.lib.home}/lib"/>
  <property name="terasoluna.lib.dir" value="${terasoluna.lib.home}/dist"/>
  <tstamp/>

  <!-- クラスパスの設定 -->
  <property name="classpath.lib"
    value="${lib.dir}/antlr-2.7.6.jar;
  	    ${lib.dir}/commons-beanutils-1.7.0.jar;
        ${lib.dir}/commons-digester-1.8.jar;
        ${lib.dir}/commons-fileupload-1.2.jar;
        ${lib.dir}/commons-jxpath-1.2.jar;
        ${lib.dir}/commons-lang-2.3.jar;
        ${lib.dir}/commons-logging-1.1.jar;
        ${lib.dir}/commons-validator-1.3.1.jar;
        ${lib.dir}/jakarta-oro-2.0.8.jar;
        ${lib.dir}/jsp-api.jar;
        ${lib.dir}/servlet-api.jar;
  	    ${lib.dir}/spring.jar;
        ${lib.dir}/struts.jar;
  	    ${terasoluna.lib.dir}/terasoluna-commons.jar;"/>

  <!-- =================================
	     ライブラリがあるかチェック
	   ================================= -->
  <target name="checkDependencyProject">
  	<available type="dir" file="${terasoluna.lib.home}/lib"
  			property="terasoluna-lib.exist" />
    <fail unless="terasoluna-lib.exist"
    	message="ビルドを実行するにはterasoluna-libプロジェクトが必要です。"/>
  </target>

  <!-- =================================
	      依存するjarの更新
	   ================================= -->
  <target name="buildDependencyJar"
  	description="依存する他のTERASOLUNAプロジェクトをビルドする" >
  	<available file="${terasoluna.commons.home}/ant/build.xml"
  	  			property="terasoluna-commons.exist"/>
  	<antcall target="buildTerasolunaCommonsJar"/>
  </target>

  <!-- =================================
	      ローカルのTERASOLUNA依存プロジェクトをビルドする
	   ================================= -->
  <target name="buildTerasolunaCommonsJar" if="terasoluna-commons.exist">
  	<ant antfile="${terasoluna.commons.home}/ant/build.xml"
  		target="jar" inheritall="false"/>
  </target>

  <!-- =================================
	       クラスファイルの削除を行う。
	   ================================= -->
  <target name="clean" description="クラスファイルの削除">
    <delete includeEmptyDirs="true" failonerror="false">
	  <fileset dir="${class.dir}" includes="**/*"/>
	</delete>
  </target>

  <!-- =================================
	       コンパイルを行う。
	   ================================= -->
  <target name="compile" depends="clean" description="コンパイル実行">
  	<mkdir dir="${class.dir}"/>
  	<javac srcdir="${source.dir}"
	    destdir="${class.dir}"
	    classpath="${classpath.lib}"
  		nowarn="true"
	    debug="on" />
    <copy todir="${class.dir}">
  	  <fileset dir="${source.dir}">
  		<include name="**/*.js"/>
  		<include name="**/*.dtd"/>
  	  </fileset>
    </copy>
  </target>

  <!-- =================================
        　　Jarファイルを作成する
            設定ファイル類と作成したJarファイルをterasoluna-libにコピーする
       ================================= -->
  <target name="jar" depends="checkDependencyProject,buildDependencyJar,compile">
  	<delete file="${dist.dir}/${ant.project.name}.jar"/>
  	<mkdir dir="${dist.dir}"/>
  	<jar destfile="${dist.dir}/${ant.project.name}.jar">
      <manifest>
        <!-- attribute name="Built-By" value="${user.name}"/ -->
      	<attribute name="Extension-Name" value="${ant.project.name}" />
        <attribute name="Implementation-Title" value="TERASOLUNA Framework for Java"/>
        <attribute name="Implementation-Version" value="${terasoluna.version} ${TODAY}"/>
        <attribute name="Implementation-Vendor" value="NTT DATA Corporation."/>
      </manifest>
      <fileset dir="${class.dir}"/>
    </jar>
  	<copy todir="${terasoluna.lib.home}/dist"
  	  		file="${dist.dir}/${ant.project.name}.jar"/>
  	<copy todir="${terasoluna.lib.home}/conf/thin">
  		<fileset dir="./image">
  			<include name="calendar/**/*.*"/>
  		</fileset>
  		<fileset dir="./tld">
  			<include name="*.tld"/>
  		</fileset>
  		<fileset dir="./javaScript">
  			<include name="*.js"/>
  		</fileset>
  		<fileset dir="./styleSheet">
  			<include name="*.css"/>
  		</fileset>
  		<fileset dir="./conf">
  			<include name="*.*"/>
  		</fileset>
  		<fileset dir="./properties">
  			<include name="*.properties"/>
  		</fileset>
  	</copy>
  </target>

  <!-- =================================
	      　ソースコードを圧縮したZipファイルを作成する
       ================================= -->
  <target name="createSourceZip">
  	<delete file="${dist.dir}/${ant.project.name}-src_${terasoluna.version}.zip"/>
  	<mkdir dir="${dist.dir}"/>
  	<zip destfile="${dist.dir}/${ant.project.name}-src_${terasoluna.version}.zip"
        basedir="${source.dir}" />
  	<copy todir="${terasoluna.lib.home}/src"
  	  		file="${dist.dir}/${ant.project.name}-src_${terasoluna.version}.zip"/>
  </target>

  <!-- =================================
	       JavaDocの生成を行う。
       ================================= -->
  <target name="createJavaDoc" description="JavaDoc生成">
    <delete dir="./doc/javadoc" />
    <mkdir dir="./doc/javadoc" />
    <javadoc classpath="${classpath.lib}" 
    	sourcepath="${source.dir}" destdir="./doc/javadoc"
        doctitle="${ant.project.name}" windowtitle="${ant.project.name}"
        use="true" splitindex="true"
        encoding="Windows-31J"
        private="true"
        packagenames="**/*">
    </javadoc>
  </target>

  <!-- =================================
	      　JavaDoc圧縮したZipファイルを作成する
       ================================= -->
  <target name="createJavaDocZip" depends="createJavaDoc">
  	<delete file="${terasoluna.lib.home}/doc/${ant.project.name}-javadoc_${terasoluna.version}.zip"/>
  	<mkdir dir="${terasoluna.lib.home}/doc/"/>
  	<zip destfile="${terasoluna.lib.home}/doc/${ant.project.name}-javadoc_${terasoluna.version}.zip"
        basedir="${basedir}/doc/javadoc/" />
  	<delete failonerror="false">
  	  <fileset dir="${basedir}/doc/javadoc">
	    <include name="**/*" />
      </fileset>
    </delete>
  	<delete dir="${basedir}/doc/javadoc"/>
  	<delete dir="${basedir}/doc"/>
  </target>	
	
  <!-- =================================
        このプロジェクトをZipファイルにしてdistフォルダに格納する。
       ================================= -->
  <target name="zip">
  	<delete file="${dist.dir}/${ant.project.name}_${terasoluna.version}.zip"/>
  	<mkdir dir="${dist.dir}"/>
   	<zip destfile="${dist.dir}/${ant.project.name}.zip">
	  <fileset dir="${basedir}/..">
	    <include name="${ant.project.name}/.classpath"/>
	  	<include name="${ant.project.name}/.project"/>
	  	<include name="${ant.project.name}/sources/**/*"/>
	  	<include name="${ant.project.name}/ant/**/*"/>
	  	<include name="${ant.project.name}/conf/**/*"/>
	  	<include name="${ant.project.name}/image/**/*"/>
  		<include name="${ant.project.name}/javaScript/**/*"/>
	  	<include name="${ant.project.name}/properties/**/*"/>
  		<include name="${ant.project.name}/styleSheet/**/*"/>
  		<include name="${ant.project.name}/tld/**/*"/>
	  	<include name="${ant.project.name}/testcases/testsources/**/*"/>
	  	<include name="${ant.project.name}/LICENSE.txt"/>
	  	<exclude name="${ant.project.name}/ant/jensitybuild.*"/>
	  	<exclude name="${ant.project.name}/ant/testbuild.*"/>
	  </fileset>
    </zip>
  	<rename dest="${dist.dir}/${ant.project.name}_${terasoluna.version}.zip" 
  		src="${dist.dir}/${ant.project.name}.zip"/>
  </target>
</project>

