0 Replies Latest reply on May 21, 2012 6:32 AM by 937323

    How to create a jar from a java project in the file system Using ANT tool

      I have a java project in a local system and i am trying to create an automate "jar" file . The project contains main folder with sub-folders .Just tell me how build.xml is created for building a jar.


      <project name="MCMPCoreEngine" basedir="." default="main">

      <property name="src.dir" value="src"/>
      <property name="external.lib.dir" value="lib"/>
      <property name="external.lib" value="${external.lib.dir}/DCFJars"/>
      <property name="external.jar" value="${external.lib.dir}/ThunderheadJars"/>

      <property name="build.dir" value="build"/>
      <property name="classes.dir" value="${build.dir}/classes"/>
      <property name="jar.dir" value="${build.dir}/jar"/>

      <path id="mcmpcoreengine.classpath">
      <fileset dir="${external.lib.dir}"/>
      <fileset dir="${external.lib}"/>
      <fileset dir="${external.jar}"/>
      <include name="*.jar"/>

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

      <target name="compile">
      <mkdir dir="${classes.dir}"/>

      <javac srcdir="${src.dir}" destdir="${classes.dir}">
      <classpath refid="mcmpcoreengine.classpath"/>


      <target name="jar" depends="compile">
      <mkdir dir="${jar.dir}"/>
      <jar destfile="${jar.dir}/MCMPCoreEngine.jar" basedir="${classes.dir}">


      <target name="run" depends="jar">
      <java jar="${jar.dir}/MCMPCoreEngine.jar" fork="true"/>

      <target name="clean-build" depends="clean,jar"/>

      <target name="main" depends="clean,run"/>