I've looked at a bunch of different examples, and tried several variations, but can't seem to get this working correctly. It also appears that you can't exclude an entire directory with javac, but only files, which I suppose means you can't specify a package? Here is what I have:
<javac srcdir="src" destdir="WEB-INF/classes" excludes="path/to/excluded/package/*.java">
<classpath refid="compile.classpath"/> <!-- reference defined earlier -->
</javac>
You can exclude whole directories or directory trees with "**" and exclude. Example
Mike, another way to to tell javac to explicitly not access certain files is to unset sourcepath. I just figured this out...
From the Ant manual:
The javac task implicity includes all files in the srcdir and you can just add an exclude element to the task, for example:
This would not compile any of the classes in the
my.package.test
package.Please note that excludes does not work if any of the files in "src" (or in "includes" if specified) have dependency in the files specified in excludes. So first ensure that files excluded are not referred in any of the include files.