Javac with classpath : Compile « Ant « Java

Javac with classpath

<?xml version="1.0"?>

<project name="yourName" default="junitgui" basedir=".">
  <property name="junitJar" value="\junit3.8.1\junit.jar" />
  <property name="src.dir" value="${basedir}\src" />
  <property name="build.dir" value="${basedir}\classes" />

  <path id="classpath">
    <pathelement location="${junitJar}" />
    <pathelement location="${build.dir}" />

  <target name="init">
    <mkdir dir="${build.dir}" />

  <target name="build" depends="init" description="build all">
        srcdir="${src.dir}" destdir="${build.dir}"
        deprecation="on" debug="on" optimize="off" includes="**">
      <classpath refid="classpath" />

  <target name="junitgui" depends="build" description="run junitgui">
    <java classname="junit.awtui.TestRunner" fork="yes">
      <arg value="sis.AllTests" />
      <classpath refid="classpath" />

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

   <target name="rebuildAll" depends="clean,build" description="rebuild all"/>


Related examples in the same category

1.Compile the web application
2.Ant target:compile
3.Compile the stand-alone application
4.Use a precompiler with Java
5.Indicate the init and max memory when compiling
6.Ant Javac setting
7.Ant javac includes
8.Javac include and exclude
9.Javac with encoding
10.Javac with optimize
11.Set debug and optimize for javac
12.Set failonerror for javac
13.Set debuglevel for javac
14.Set link for Javac
15.Set source version in javac
16.Set target for javac
17.Ant compile from src folder to build folder, set the class path and java files include