Wildish, Joe STASCO-OTO/72 wrote:
All,
New to the list, not new to ANT. Am using v1.6.5. I've had a scan through the
archives of this list but I can't find an answer to my question.. so here goes:
I have two source roots, root_a and root_b. Beneath those directories are some
source files, some of which are for the same class. e.g.
root_a/package/One.java
root_a/package/Two.java
root_b/package/Two.java
root_b/package/Three.java
I want to compile up the source files of my choosing, without copying files around to
temporary areas (I can achieve what I want via copy, but I should be able to do it just
via javac). Let's say that I want to choose "package.Two" from the root_b
directory; if this was command line, I could do the following:
$ mkdir classes
$ javac -d classes root_a/package/One.java root_b/package/Two.java
root_b/package/Three.java
... and it would work fine. However, I can't seem to replicate this in an ANT
target. As filesets are relative to the specificed directory, I cannot find a
way to exclude certain files from one source root, as effectively I am working
within the same namespace.
What I really want to do is something like this:
<javac destdir="classes">
<src>
<fileset dir="root_a">
<include name="**/*.java"/>
<exclude name="package/Two.java"/>
</fileset>
<fileset dir="root_b">
<include name="**/*.java"/>
</fileset>
</src>
</javac>
However, the src attribute of javac is only looking for directories (to then
recursively scan), so that does not work. Any help would be appreciated.
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]