toagit
7/13/2015 - 8:50 AM

ant build sample. contain javac, javadoc, zip.

ant build sample. contain javac, javadoc, zip.

<?xml version="1.0" encoding="Windows-31J"?>
<project name="builSample" default="main" basedir=".">
  <property name="path.lib" location="./lib"/>
  <property name="path.out" location="./dest"/>
  <property name="path.bin" location="${path.out}/bin"/>
  <property name="path.src" location="./src"/>
  <property name="path.test" location="./srctest"/>
  <property name="path.doc" location="${path.out}/javadoc"/>
  <property name="compiler" value="JAVA_HOME\bin\javac"/>
  
  <path id="classpath">
    <fileset dir="${path.lib}">
      <include name="*.jar" />
    </fileset>
  </path>
  
  <target name="main">
    <antcall target="makeJar" />
    <antcall target="makeJavadoc" />
    <antcall target="makeZip" />
  </target>
  
  <target name="clean" description="dest dir clean">
    <delete dir="${path.out}" />
    <mkdir dir="${path.out}" />
    <mkdir dir="${path.bin}" />
    <mkdir dir="${path.doc}" />
  </target>
  
  <target name="compile" depends="clean" >
    <echo message="Start Compile" />
    <javac includeantruntime="false" srcdir="${path.src}" destdir="${path.bin}" classpathref="classpath" executable="${compiler}">
      <compilerarg value="-Xlint:unchecked" />
      <include name="**/*.java" />
    </javac>
  </target>
  
  <target name="makeJar" depends="compile" >
    <echo message="Start Make Jar" />
    <jar basedir="${path.bin}" destfile="${path.lib}/hoge.jar" />
  </target>
  
  <target name="makeJavadoc">
    <echo message="make javadoc start" />
    <javadoc windowtitle="${ant.project.name} javadoc" destdir="${path.doc}" encoding="MS932" docencodeing="UTF-8" charset="UTF-8">
      <sourcepath path="${path.src}" />
      <classpath refid="classpath" />
      <package name="com.toagit.tools" />
    </javadoc>  
  </target>
  
  <target name="makeZip" >
    <zip destfile="${path.out}\hoge.zip">
      <zipfileset dir="." prefix="${ant.project.name}" 
        <include name="**/*java" />
        <include name="lib/**" />
        <include name="*bat" />
      </zipfileset>
    </zip
  </target>
</project>