Using Javamake with Ant

Javamake can be used instead of the standard javac Ant task. It takes all of the usual javac parameters (attributes) such as srcdir, destdir or classpath, and can use any Java compiler specified with the build.compiler Ant property. An optional property that javamake recognizes is called javamake.pdb.filename and is used to specify non-default project database file name/location. By default, the project database will be given the standard javamake.pdb name and will be placed in the directory from which you invoke Ant.

To start using javamake instead of javac in your project, simply add the full paths to javamake.jar and javamake-antXXX.jar (where XXX is either "141" or "15", depending on the version of Ant that you use, 1.4.1 or 1.5 respectively) to your CLASSPATH, and add the following line to your build file:

<taskdef name="javamake" classname="com.sun.tools.javamake.ant.JavaMake"/>
Then replace javac with javamake everywhere in your build file.

To specify that the project database should be named differently, say myproject.pdb in classes subdirectory of your working directory, use the pdbFilename argument of the javamake task, e.g.

<javamake srcdir="src" destdir="classes" pdbFilename="classes/myproject.pdb"/>
Alternatively, a single global project database can be specified by adding a line such as
<property name="javamake.pdb.filename" value="classes/myproject.pdb"/>
Starting from Javamake release 1.3, you may add to the project all classes contained in specified JAR files, along with "normal" classes generated from .java sources. To add some JARs to your project, use the special projclasspath argument. Its usage is the same as for the standard classpath argument, and when the Java compiler is invoked, these two paths are merged and passed to it. Here is an example of the Javamake task that uses this argument:

<javamake
    srcdir="${src}"
    destdir="${build}"
    classpath="."
    projclasspath="myjars/test.jar"
    failondependentjar="true"
/>
IMPORTANT: Starting from Javamake release 1.2.15, there are two versions of the javamake task adapter class, contained in javamake-ant141.jar and javamake-ant15.jar archives, respectively. The former version has been tested to work correctly with Ant 1.4.1. It also works with Ant 1.5, although it does not support all the parameters that are provided in the javac standard task in Ant 1.5. The latter version of the javamake adapter class works with Ant starting from release 1.5. If you use Ant 1.5 or later release, it is recommended that you use this version, since there is no guarantee that the other one will work correctly with future releases of Ant. None of the above adapter classes will work with releases of Ant earlier than 1.4.1, since these classes use some methods of the original javac task that appeared only in Ant 1.4.1.

To download the source code of the Javamake task, go to the download page.