Sitemap

Thursday, June 25, 2015

Java: Apache Ant

build.properties
src.dir=src
classes.dir=classes
main-class=com.mypkg.PortfolioManager
lib.dir=lib
docs.dir=docs
projectName=AntTutorial

build.xml
<?xml version="1.0" encoding="windows-1252" ?>
<!--Ant buildfile generated by Oracle JDeveloper-->
<!--Generated Apr 20, 2015 4:09:46 PM-->
<project xmlns="antlib:org.apache.tools.ant" name="Project" default="all" basedir=".">
  <property file="build.properties"/>

  <target name="clean">
    <delete dir="${classes.dir}"/>
    <delete dir="${docs.dir}"/>
  </target>

  <target name="init">
    <mkdir dir="${classes.dir}"/>
    <!--<mkdir dir="${docs.dir}"/>-->
  </target>

  <path id="classpath">
    <fileset dir="${lib.dir}" includes="**/*.jar"/>
  </path>

  <target name="compile" depends="init">
    <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
  </target>

  <!--<target name="docs" depends="compile">
    <javadoc packagenames="src" sourcepath="${src.dir}" destdir="${docs.dir}">
       <fileset dir="${src.dir}">
                <include name="**" />
           </fileset>
    </javadoc>
  </target>-->

  <target name="jar" depends="compile">
    <jar destfile="${projectName}.jar" basedir="${classes.dir}">
      <manifest>
        <attribute name="Main-Class" value="${main-class}"/>
      </manifest>
    </jar>
  </target>

  <target name="main" depends="clean,compile,jar"/>
</project>

Download the sample project from the file cabinet: AntTut.zip
More Info: http://www.tutorialspoint.com/ant/index.htm

No comments:

Post a Comment