<?xml version="1.0" ?>
<project name="taglib-doc-sample" default="buildmain">

<!-- \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210 -->
    <!-- \u30bd\u30fc\u30b9\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea -->
    <property name="src" value="${basedir}/src" />
        <!-- \u4f5c\u6210\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u672c\u4f53\u683c\u7d0d\u7528 -->
	<property name="src.main" value="${src}/main" />
	<!-- \u30c6\u30b9\u30c8\u683c\u7d0d\u7528 -->
        <property name="src.test" value="${src}/test" />
	<!-- WEB\u30c6\u30b9\u30c8\u683c\u7d0d\u7528 -->
        <property name="src.webtest" value="${src}/webtest" />

    <!-- \u30af\u30e9\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea -->
    <property name="build" value="${basedir}/build" />
        <!-- \u30d7\u30ed\u30b0\u30e9\u30e0\u672c\u4f53\u683c\u7d0d\u7528 -->
	<property name="build.main" value="${build}/main" />
	<!-- \u30c6\u30b9\u30c8\u683c\u7d0d\u7528 -->
	<property name="build.test" value="${build}/test" />
	<!-- WEB\u30c6\u30b9\u30c8\u683c\u7d0d\u7528 -->
	<property name="build.webtest" value="${build}/webtest" />

    <!-- \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea -->
    <property name="doc" value="${basedir}/doc" />
        <!-- JavaDoc\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea -->
        <property name="doc.javadoc.dir" value="${doc}/javadoc/" />
        <!-- \u30c6\u30b9\u30c8\u30ec\u30dd\u30fc\u30c8 -->
        <property name="doc.testreport" value="${doc}/testreport" />
            <property name="doc.testreport.xml.dir" value="${doc.testreport}/xml" />
            <property name="doc.testreport.html.dir" value="${doc.testreport}/html" />
        <!-- taglibdoc\u7528\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea -->
        <property name="taglibdoc.dir" value="${doc}/taglibdoc" />
        <property name="taglibreport.dir" value="${doc}/taglibreport" />
        <property name="stylesheets.dir" value="${doc}/stylesheets/" />

    <!-- \u30e9\u30a4\u30d6\u30e9\u30ea -->
    <property name="lib" value="${basedir}/lib" />

    <!-- \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u683c\u7d0d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea -->
    <property name="download.dir" value="${basedir}/download" />

    <!-- taglibdoc\u7528\u8a2d\u5b9a -->
    <property name="struts.source.file" value="jakarta-struts-1.1-src.zip" />
    <property name="taglibdocs.jar" value="${lib}/taglib-docs.jar" />
    <property name="taglib.xml.dir" value="${src.main}/taglibxml" />

<!-- ===================================================-->
<!-- \u30d7\u30ed\u30b0\u30e9\u30e0\u672c\u4f53\u3092\u30d3\u30eb\u30c9 -->
<target name="buildmain" depends="init"
        description="Build application.">
  <native2ascii src="${src.main}" dest="${build.main}"
	  includes="**/*.eucjp"
	  ext="" encoding="EUC_JP"/>	
  <native2ascii src="${basedir}" dest="${basedir}"
    includes="log4j.xml.eucjp"
    ext="" encoding="EUC_JP" />
  <javac srcdir="${src.main}" destdir="${build.main}" encoding="EUC_JP">
    <classpath>
      <fileset dir="lib">
        <include name="**/*.jar" />
      </fileset>
    </classpath>
  </javac>
</target>

<!-- \u30c6\u30b9\u30c8\u3092\u30d3\u30eb\u30c9 -->
<target name="buildtest" depends="jar"
        description="Build test.">
  <javac srcdir="${src.test}" destdir="${build.test}">
    <classpath>
      <fileset dir="lib">
        <include name="**/*.jar" />
      </fileset>
    </classpath>
  </javac>
</target>

<!-- \u30c6\u30b9\u30c8\u3092\u5b9f\u884c -->
<target name="test" depends="buildtest"
        description="Test by executing JUnit.">
  <junit fork="yes" haltonfailure="no">
    <classpath>
      <fileset dir="lib">
        <include name="**/*.jar" />
      </fileset>
      <pathelement path="${build.test}" />
    </classpath>

    <formatter type="xml"/>

    <batchtest fork="yes" todir="${doc.testreport.xml.dir}">
      <fileset dir="${src.test}">
        <include name="**/*Test*.java" />
        <exclude name="**/AllTests.java" />
      </fileset>
    </batchtest>
  </junit>

  <!-- \u30c6\u30b9\u30c8\u306e\u30ec\u30dd\u30fc\u30c8 -->
  <junitreport todir="${doc.testreport.html.dir}">
    <fileset dir="${doc.testreport.xml.dir}">
      <include name="**/TEST-*.xml" />
    </fileset>
    <report format="frames" todir="${doc.testreport.html.dir}" />
  </junitreport>
</target>

<!-- WEB\u30c6\u30b9\u30c8\u3092\u30d3\u30eb\u30c9 -->
<target name="buildwebtest" depends="jar"
  if="warfile.name" description="create test war file.">
  <javac srcdir="${src.webtest}" destdir="${build.webtest}">
    <classpath>
      <fileset dir="lib">
        <include name="**/*.jar" />
      </fileset>
    </classpath>
  </javac>

  <native2ascii src="${src.webtest}/WEB-INF" dest="${src.webtest}/WEB-INF"
    includes="**/*.eucjp"
    ext="" encoding="EUC_JP" />

  <native2ascii src="${src.webtest}/" dest="${build.webtest}/"
    includes="**/*.eucjp"
    ext="" encoding="EUC_JP" />

  <native2ascii src="${src}/WEB-INF" dest="${src.webtest}/WEB-INF"
    includes="**/*.eucjp"
    ext="" encoding="EUC_JP" />

  <war warfile="${webtest.warfile.name}"
       webxml="${src.webtest}/WEB-INF/web.xml"
       excludes="**/*Test*,**/*.java,**/*~" >
    <fileset dir="${src}/jsp" />
    <fileset dir="${src}/html" />
    <fileset dir="${src.webtest}/jsp" />
    <fileset dir="${src.webtest}/html" />
    <fileset dir="${src.webtest}/xsl" />
    <webinf dir="${src.webtest}/WEB-INF" >
      <include name="**/*" />
      <exclude name="web.xml" />
    </webinf>
    <lib dir="${lib}" />
    <classes dir="${build.webtest}/" />
  </war>
</target>

<!-- Web\u30c6\u30b9\u30c8\u3092\u5b9f\u884c -->
<target name="webtest" depends="buildwebtest"
        description="Test by executing JUnit and Cactus.">
  <junit fork="yes" haltonfailure="no">
    <classpath>
      <fileset dir="lib">
        <include name="**/*.jar" />
      </fileset>
      <pathelement path="${build.webtest}" />
    </classpath>

    <formatter type="xml"/>

    <batchtest fork="yes" todir="${doc.testreport.xml.dir}">
      <fileset dir="${src.webtest}">
        <include name="**/*Test*.java" />
        <exclude name="**/AllTests.java" />
      </fileset>
    </batchtest>
  </junit>

  <!-- \u30c6\u30b9\u30c8\u306e\u30ec\u30dd\u30fc\u30c8 -->
  <junitreport todir="${doc.testreport.html.dir}">
    <fileset dir="${doc.testreport.xml.dir}">
      <include name="**/TEST-*.xml" />
    </fileset>
    <report format="frames" todir="${doc.testreport.html.dir}" />
  </junitreport>
</target>

<!-- \u30d7\u30ed\u30b0\u30e9\u30e0\u672c\u4f53\u3092\u5b9f\u884c -->
<target name="run" depends="jar"
        description="Run application.">
  <java dir="${build.main}" classname="${application.class}" fork="yes">
    <classpath>
      <fileset dir="lib">
        <include name="*.jar" />
      </fileset>
    </classpath>
  </java>
</target>

<!-- JavaDoc\u4f5c\u6210 -->
<target name="javadoc" depends="init"
        description="Make JavaDoc from source of application and test.">
  <javadoc packagenames="${javadoc.package.name}"
           sourcepath="${src.main}"
           destdir="${doc.javadoc.dir}"
           author="true"
           version="true"
           use="true"
           private="true"
           splitindex="true"
           doctitle="&lt;h1&gt;${application.name}-${version}&lt;/h1&gt;"
           bottom="&lt;i&gt;Copyright 2002 Matsu All Rights Reserved.&lt;/i&gt;">	 
  </javadoc>
</target>

<!-- dia2code\u3092\u5b9f\u884c \u30d7\u30ed\u30d1\u30c6\u30a3diafile\u3092\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b -->
<target name="dia2code" depends="init" if="diafile"
        description="Execute &quot;dia2code&quot;.You need to describe the property &quot;diafile&quot; in build.xml.">
  <delete dir="${diagensrc}/*" />
  <mkdir dir="${diagensrc}" />
  <exec os="Linux" executable="dia2code">
    <arg line="-t java" />
    <arg line="-d ${diagensrc}" />
    <arg file="${diafile}" />
  </exec>
</target>

<!-- JAR\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210 -->
<target name="jar" depends="buildmain" if="jarfile.name" description="create jar file.">
  <jar jarfile="${lib}/${jarfile.name}"
       basedir="${build.main}"
       manifest="${src}/main/MANIFEST.MF" />
</target>

<!-- WAR\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210 -->
<target name="war" depends="jar" if="warfile.name" description="create war file.">
  <native2ascii src="${src}/WEB-INF" dest="${src}/WEB-INF"
  includes="**/*.eucjp"
  ext="" encoding="EUC_JP" />
  <war warfile="${warfile.name}"
       webxml="${src}/WEB-INF/web.xml"
       excludes="**/*Test*,**/*.java,**/*~" >
    <fileset dir="${src}/jsp" />
    <fileset dir="${src}/html" />
    <webinf dir="${src}/WEB-INF" >
      <include name="**/*" />
      <exclude name="web.xml" />
    </webinf>
    <lib dir="${lib}" />
  </war>
</target>

<!-- \u914d\u5e03\u7528tgz\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210 -->
<target name="dist" if="dist" description="create tgz file for distribute.">
  <delete dir="dist_tmp/${dist}" />
  <mkdir dir="dist_tmp/${dist}" />
  <copy todir="dist_tmp/${dist}">
    <fileset dir="${basedir}">
      <include name="ChangeLog" />
      <include name="build.*"/>
      <include name="log4j.*"/>
      <include name="gcmon.conf"/>
      <include name="title_image.png"/>
      <include name="LICENSE"/>
    </fileset>
  </copy>
  <copy todir="dist_tmp/${dist}">
    <fileset dir="${basedir}">
      <include  name="src/**/*" />
      <exclude name="**/CVS" />
      <exclude name="src/test" />
    </fileset>
  </copy>
  <tar tarfile="${basedir}/${dist}.tar" basedir="${basedir}/dist_tmp"/>
  <gzip zipfile="${basedir}/${dist}.tar.gz" src="${basedir}/${dist}.tar" />
  <delete file="${basedir}/${dist}.tar"/>
  <delete dir="dist_tmp/" />
</target>

<!--==== \u521d\u671f\u5316 ==== -->
<!-- build.xml\u3092native2ascii -->
<target name="n2abuildxml" description="native2ascii native-build.xml to build.xml">
  <native2ascii src="${basedir}" dest="${basedir}"
  includes="*build.xml.eucjp"
  ext="" encoding="EUC_JP" />
  <native2ascii src="${basedir}" dest="${basedir}"
    includes="*build.properties.eucjp"
    ext="" encoding="EUC_JP" />
</target>

<!-- \u521d\u671f\u5316.\u5404\u30bf\u30fc\u30b2\u30c3\u30c8\u3067\u5fc5\u8981\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210 -->
<target name="init" depends="init-webapp"
        description="Make directories for source and build and doc.">
  <mkdir dir="${src.main}" />
  <mkdir dir="${src.test}" />
  <mkdir dir="${build.main}" />
  <mkdir dir="${build.test}" />
  <mkdir dir="${doc}" />
  <mkdir dir="${doc.javadoc.dir}" />
  <mkdir dir="${doc.testreport.xml.dir}" />
  <mkdir dir="${doc.testreport.html.dir}" />
  <mkdir dir="${lib}" />
</target>

<!-- Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5834\u5408\u306e\u521d\u671f\u5316 -->
<target name="init-webapp" if="warfile.name" >
  <mkdir dir="${src}/jsp" />
  <mkdir dir="${src}/html" />
  <mkdir dir="${src}/WEB-INF" />
  <mkdir dir="${src.webtest}/jsp" />
  <mkdir dir="${src.webtest}/html" />
  <mkdir dir="${src.webtest}/xsl" />
  <mkdir dir="${src.webtest}/WEB-INF" />
  <mkdir dir="${build.webtest}" />
</target>

<!-- ==== \u6383\u9664 ==== -->
<!-- \u6383\u9664.\u305f\u3060\u3057src\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f*~\u30d5\u30a1\u30a4\u30eb\u4ee5\u5916\u6d88\u3055\u306a\u3044. -->
<target name="clean"
        description="Remove directories, build and doc.Source Directories will NOT be removed.">
  <delete verbose="true">
    <fileset dir="${doc}" />
    <fileset dir="${build}" />
    <fileset dir="${lib}" includes="${jarfile.name}" />
    <fileset dir="${basedir}" includes="${warfile.name}" />
    <fileset dir="${basedir}" includes="${webtest.warfile.name}" />
    <fileset dir="${diagensrc}" />
    <!-- \u306a\u305c\u304b\u6a5f\u80fd\u3057\u306a\u3044 -->
    <fileset dir="${src}" includes="**/*~" />
  </delete>
</target>

<!-- taglibdoc\u306e\u305f\u3081\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9 -->
<target name="taglibdocs.download" description="download files." >
  <mkdir dir="${download.dir}" />
  <get src="http://sunsite.tus.ac.jp/pub/apache/jakarta/struts/source/${struts.source.file}"
       dest="${download.dir}/${struts.source.file}"  verbose="true" usetimestamp="true"/>
</target>

<!-- taglibdoc\u306e\u305f\u3081\u306e\u6e96\u5099 -->
<target name="taglibdocs.prepare" description="prepare for generate taglibdocs">
  <unzip src="${download.dir}/${struts.source.file}" dest="${download.dir}" />
  <ant antfile="${download.dir}/jakarta-struts-1.1-src/contrib/tag-doc/build.xml"
           dir="${download.dir}/jakarta-struts-1.1-src/contrib/tag-doc/"
        target="dist" />
  <copy file="${download.dir}/jakarta-struts-1.1-src/contrib/tag-doc/dist/taglib-docs.jar"
        todir="${lib}" />
  <copy file="${download.dir}/jakarta-struts-1.1-src/doc/stylesheets/tld.xsl"
        todir="${stylesheets.dir}" />
</target>

<!-- taglibdoc\u4f5c\u6210 -->
<target name="taglibdoc" description="generate taglibdoc.">
  <taskdef name="taglibdoc" 
       classname="org.apache.struts.taskdefs.TaglibDoc">
    <classpath path="${taglibdocs.jar}"/>
  </taskdef>

  <taglibdoc destdir="${taglibdoc.dir}">
    <fileset dir="${taglib.xml.dir}">
      <include name="*.xml"/>
    </fileset>
  </taglibdoc>
</target>
  
<!-- taglibreport\u4f5c\u6210 -->
<target name="taglibreport" description="generate taglibreport.">
  <taskdef name="taglibreport" 
       classname="org.apache.struts.taskdefs.TaglibReport">
    <classpath path="${taglibdocs.jar}"/>
  </taskdef>

  <taglibreport destdir="${taglibreport.dir}">
    <fileset dir="${taglib.xml.dir}">
      <include name="*.xml"/>
    </fileset>
  </taglibreport>
</target>

<!-- TLD\u30d5\u30a1\u30a4\u30eb\u306e\u751f\u6210 -->
<target name="tld" description="generate tld file.">
  <style basedir="${taglib.xml.dir}"
         destdir="${src.main}/WEB-INF"
         extension=".tld"
         style="${stylesheets.dir}/tld.xsl"
         includes="*.xml"/>
</target>

<!-- taglibdoc\u95a2\u9023\u30bf\u30fc\u30b2\u30c3\u30c8\u306e\u30c6\u30b9\u30c8 -->
<target name="taglibdocs.test" description="test taglibdocs targets.">
  <copy todir="${taglib.xml.dir}" >
    <fileset dir="${download.dir}/jakarta-struts-1.1-src/doc/userGuide/">
      <include name="struts-*.xml"/>
    </fileset>
  </copy>
  <antcall target="tld" />
  <antcall target="taglibdoc" />
  <antcall target="taglibreport" />
</target>

</project>

