Bug 37148 - javac nested <src> element troube with excludes
Summary: javac nested <src> element troube with excludes
Status: RESOLVED INVALID
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.6.5
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-18 19:25 UTC by John Broglio
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments
demonstrates the bug, in ant 1.6.5 (2.17 KB, application/x-zip)
2006-10-20 14:06 UTC, Peter Maloney
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Broglio 2005-10-18 19:25:38 UTC
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)

=============================
Comment 1 Juergen Weber 2005-12-28 16:45:11 UTC
Same for me,

<javac 
	excludes="....">
	     <src path="${src}"/>
	     <src ....

just ignores the excludes part.
Comment 2 Peter Reilly 2006-09-14 21:52:49 UTC
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.



  
   
Comment 3 Peter Maloney 2006-10-20 14:02:21 UTC
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.
Comment 4 Peter Maloney 2006-10-20 14:06:11 UTC
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)
Comment 5 Matt Benson 2006-10-20 14:22:27 UTC
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.
Comment 6 Dominique Devienne 2006-10-20 15:50:29 UTC
FYI: You can prevent <javac> to be greedy by specifying an explicit empty 
sourcepath, as in <javac sourcepath="" ...>. --DD