Hi Steve,

Thanks for the suggestion; however, the "src" attribute is a path-like 
structure, and as such you cannot use include or exclude elements (hence trying 
to use the filesets in the first example).

It would seem that the javac task is taking directories specified by the "src" 
attribute, and then scanning beneath these for the Java files to compile. 
However, there does not appear to be a way to specify a fileset /per src 
directory/, as the only place it is legitimate to include/exclude is as a 
direct child of the javac task itself (which makes sense as it's an implicit 
fileset) -- unfortunately though, by this time, it is impossible to write an 
include/exclude as there is no way to distinguish which source files need to 
have the rule applied!

I agree this is not a nice situation (it's to do with generated source 
files)... I can achieve what I need by staging the source files into a 
temporary directory, and then compiling; I was simply trying to avoid that. 
However, I don't agree that it is out of the hands of ANT. I can actually 
achieve what I am trying to do by using the command line - by explicitly 
listing each source file when calling javac:

java root_a/One.java root_b/Two.java root_b/Three.java

javac handles this OK (ie. it is not privy to root_a/Two.java, so does not 
attempt to compile it). Is the javac task not simply mimicking this behaviour? 
In which case, I should be able to emulate this within a target...?

Regards,

Joe

-----Original Message-----
From: Steve Loughran [mailto:[EMAIL PROTECTED]
Sent: 26 April 2006 10:31
To: Ant Users List
Subject: Re: Javac: multiple source roots & filesets

Have you tried multiple <src> attributes?


  <javac destdir="classes">
      <src dir="root_a">
              <include name="**/*.java"/>
              <exclude name="package/Two.java"/>
      </src>
      <src dir="root_b">
              <include name="**/*.java"/>
      </src>
  </javac>

What you are trying to do is pretty brittle. Even if you exclude 
something, the compiler itself may take a liking to the one in the same 
directory that other classes are in. There is no way to guarantee that 
root_a/package/One.java won't build against Two.java in the same dir. 
This is out of Ant's hands.

-steve

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to