At 10:35 AM 4/28/00 +0200, Kuiper, Arnout wrote:
> From: Steve Peterson [mailto:[EMAIL PROTECTED]
> I'm having an issue with the destination directory for .class
> files in Ant
> builds.  My goal is to have the .class file live in the same
> directory as
> the .java file.
>
> In my build.xml I say
>
>    <javac
>               srcdir="${src.java.dir}/com/databottling/fountain/core"
>               destdir="${src.java.dir}/com/databottling/fountain/core"
>               includes="Constants.java"
>               debug="${debug}"
>       />
>
> where <property name="src.java.dir" value="src"/>
>
> If there is a Constants.class in the destdir, javac will
> overwrite that
> with the newly created .class.  If there isn't, javac creates a
> com/databottling/fountain/core/Constants.class inside
> destdir, which isn't
> what I want.

There is a simple solution,

use destdir="${src.java.dir}". This is the root of the
class/package tree.

You might want to use srcdir="${src.java.dir}" also. Ant
will scan for sourcefiles within that tree. You can narrow
the search using includes and excludes.

Your example should look like:

<javac
  srcdir="${src.java.dir}"
  destdir="${src.java.dir}"
  includes="com/databottling/fountain/core/Constants.java"
  debug="${debug}"
/>

See the manual for more information on the include/exclude stuff.


Thanks for the feedback -- this does what I want.

I still want to press the issue a little bit regarding usability, though. Speaking as an experienced programmer but a newbie to Ant, my feeling is that the two forms above should yield the same result. Either that or you should document that srcdir _must_ point to the root of the package hierarchy.

Steve

--
Steve Peterson                               +1 952 948 9729
Principal Consultant                     FAX +1 612 677 3050
Virtation Technologies, Inc.            http://virtation.com



Reply via email to