ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wood, Alan" <>
Subject Javac and Sourcepath woes
Date Tue, 16 Apr 2002 15:14:14 GMT
Hi everyone!

I'm new to Ant, and am trying to get my first
ant build script to work correctly.  I have a batch
file system that works fine for this, but so far the
Ant method is escaping me.

I have a library that has strict layer definitions about
what layers in the library can call other layers.  To 
help enforce these restrictions, our current build 
environment builds the layers independently and uses the
proper layers (in a classpath) to compile the dependant ones.

This allows us to catch developers that have made an improper
call in the library.  (For instance, calling from the A layer
to the B layer in the example below)

The layers look like this:

B1 ---> B <--- B2
|       |      |
|       |      |
\/      \/     \/
A1 ---> A <--- A2

The full dependencies are as follows:

A is the base
A1 can call into A
A2 can call into A
B  can call into A
B1 can call into B, A1, A
B2 can call into B, A2, A

Each of these "layers" is a package, with A1/B1/A2/B2 being
subpackages of A and B respectively.

Therefore, the source structure looks like this:

(Note, the actual layers are made up of dozens of packages,
so this is somewhat simplified, but the idea should remain
the same)


Now comes the problem.

I specify my build as such for A1:

<javac  srcdir="srcdir"
    <path refid="common.classpath"/>
    <!-- Here would go a reference to the JAR of layer A -->

  <include name="A/A1/*.java"/>

The goal is for this to FAIL.  Because I haven't mentioned
the jar file for Layer A (built before this and jar'd 
already), I want the compile to fail.  Eventually, I'll
put in the jar file for A.jar into the classpath, to allow
this module to compile.

At least, that was my thought.

Here is the problem.  This still compiles!

I've tracked it down to this:

In our current build environment, we don't use the
-sourcepath command line so that javac doesn't find
the source files for layer A.  (They aren't on the
classpath, so javac's dependency check won't find them)
However, since Ant puts in the -sourcepath directive
on the command line, javac can find the source for 
layer A, and then compiles it!

This is verified since Ant reports "Compiling 4 files"
and lists the proper .java files from the A1 layer, but 
when I'm done, the compile directory has over 55 .class 
files (most of them being from the A layer)

I assume I could fix this via writing a CompilerAdapter
that uses the modern adapter and removes the sourcepath
directive from the command line, but is there a better
way to make javac ignore this??

This is going to be an issue in almost all of our code
since it all follows this pattern of layer dependency.
(Even our applications)



To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message