ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <>
Subject RE: New user with cyclic dependencies
Date Thu, 27 Jul 2000 09:30:24 GMT
> At 12:55  27/7/00 -0500, you wrote:
> >I know that if I ask javac to compile some files, and I include
> the source
> >directory as part of the classpath then javac will automatically compile
> >the imported classes as it encounters them.  It seems that ant's
> javac is
> >not doing this.
> hmmm - that so. I never knew that. In that case it may be possible to use
> this hack by specifying classpath attribute in javac that includes
> alternate source directories.

Javac, the compiler, will try to resolve class dependencies. If a class file
cannot be found, javac will look for a .java file in the same location in
the sourcepath package space and compile it.

> >I guess one solution is to include all classes with cyclic
> dependencies as
> >a single target?  I am not sure how to specify multiple
> directories for a
> >single javac task.
> well you can't and that is a design choice. I have never had to specify
> multiple source directories and am not sure it is needed thou if you could
> describe a use case where it is needed it may be possible to alter javac
> task. Ant makes a few assumptions about layout - namely that all source
> comes from one directory and that they are all in their respective package
> directories. So if you have the class in package then the src
> directory layout should be

Peter, there is no such design choice (at least, not anymore). Ant supports
multiple source paths. It does not make any assumptions about source tree
layouts. There are two ways to specify the source paths

1. Use a path in the src attribute

<javac src="../blah:..\hello;goodbye/for\now">

As I have shown here you can use either : or ; for the path separators and
either / or \ as the file separators. Ant will work out the path for your

2. Use a nested <src> element - this would be the preferred way

  <javac destdir="${build}"
    <src path="${src}" />
    <src path="${src2}" />

All of this is included in the documentation for the javac task.

Also note that ant will compile a file even if it is not in its proper
package space location. It will place the resulting class file in the proper
package space location in the destination build directory. I strongly
recommend against this practice. It means ant will always recompile the file
even if it is not out of date. Javac will also  not be able to determine the
source file if it is necessary to compile the file for a missing class.


View raw message