An excludes attribute in a javac call will work properly. But when that excludes is moved into a nested <src> element, the includes fails in a strange way. Examples: ====================================== WORKING Version with attribute "excludes" ====================================== Ant project file snippet ======================== ... <target name="game" depends="init" description="Builds the Game development version"> <mkdir dir="${testbuild}"/> <mkdir dir="${build}"/> <javac destdir="${build}" deprecation="on" debug="${debug}" optimize="${optimize}" source="1.4" target="1.4" excludes="poi/**/*"> <src><pathelement location="src"/> </src> <src><pathelement location="generated"/> </src> <classpath refid="project.class.path"/> </javac> </target> ... =================== ant output snippet =================== fileset: Setup scanner in dir /home/cafgdev/CAFG/src with patternSet{ includes: [] excludes: [poi/**/*] } [javac] com/gametable/games/cafg/client/AbilityEditor.java omitted as com/gametable/games/cafg/client/AbilityEditor.class is up to date. [javac] com/gametable/games/cafg/client/AttackEditor.java omitted as com/gametable/games/cafg/client/AttackEditor.class is up to date. ... fileset: Setup scanner in dir /home/cafgdev/CAFG/generated with patternSet{ includes: [] excludes: [poi/**/*] } ... ========================================== ===== FAILS ===== project file snippet -------------------- ... <target name="game" depends="init" description="Builds the Game development version"> <mkdir dir="${testbuild}"/> <mkdir dir="${build}"/> <javac destdir="${build}" deprecation="on" debug="${debug}" optimize="${optimize}" source="1.4" target="1.4"> <src><fileset dir="src" excludes="poi/**/*"/></src> <src><pathelement location="src"/> </src> <src><pathelement location="generated"/> </src> <classpath refid="project.class.path"/> </javac> </target> ... ================================================== ant output (note the repeated "fileset" output below which does not occur in the successful compile) ================================================== ... fileset: Setup scanner in dir /home/cafgdev/CAFG/src with patternSet{ includes: [] excludes: [poi/**/*] }fileset: Setup scanner in dir /home/cafgdev/CAFG/src with patternSet{ includes: [] excludes: [poi/**/*] } BUILD FAILED /home/cafgdev/CAFG/build.xml:47: /home/cafgdev/CAFG/src/com/gametable/games/cafg/client/AbilityEditor.java is not a directory. at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(AbstractFileSet.java:352) at org.apache.tools.ant.taskdefs.MatchingTask.getDirectoryScanner(MatchingTask.java:186) at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:751) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1068) at org.apache.tools.ant.Main.runBuild(Main.java:668) at org.apache.tools.ant.Main.startAnt(Main.java:187) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) =============================
Same for me, <javac excludes="...."> <src path="${src}"/> <src .... just ignores the excludes part.
The error is not that strange Assuming out have a directory layout: src/org/acme/A.java src/poi/C.java gen/org/acme/plane/B.java <javac srcdir="src" destdir="classes"/> corresponds to the command line: javac -sourcepath src -d classes src/org/acme/A.java src/poi/C.java <javac destdir="classes"> <src path="src"/> <src path="gen"/> </java> corresponds to: javac -d classes \ -sourcepath src src/org/acme/A.java src/poi/C.java \ -sourcepath gen gen/org/acme/plane/B.java <javac destdir="classes" excludes="poi/**/*"> <src path="src"/> <src path="gen"/> </java> corresponds to: javac -d classes \ -sourcepath src src/org/acme/A.java \ -sourcepath gen gen/org/acme/plane/B.java and <javac destdir="classes"> <src><fileset dir="src" excludes="poi/**/*"/></src> <src path="src"/> <src path="gen"/> </java> corresponds to something like: javac -sourcepath src/org/acme/A.java .. "src/org/acme/A.java" is not a directory, hence the error message.
This bug is not fixed. The way you reproduce it is to reference an excluded class in the non-excluded classes. There are 2 bugs here... One is your build script. You forgot to put a compile version of that referenced class in your build script. Two is ant. Ant is compiling and classpath-including something that is not supposed to be included at all.
Created attachment 19036 [details] demonstrates the bug, in ant 1.6.5 to go with my comment, about how to cause the bug in the newest ant release (but the solution is not always as simple as adding the class in your classpath... it doesn't work in a production build i am working on)
The REOPENED bug seems to describe something different than the original. As for Stuff.java being recompiled in the REOPENED stuff, that would be javac for you. It is a greedy compiler. What would you expect a compiler to do when you rely on an excluded class? Fail the compile? If you use a non-greedy compiler (gcj or kjc last we knew) you might see the behavior you are (?) looking for.
FYI: You can prevent <javac> to be greedy by specifying an explicit empty sourcepath, as in <javac sourcepath="" ...>. --DD