ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wood, Alan" <a.w...@genaissance.com>
Subject RE: Javac and Sourcepath woes
Date Tue, 16 Apr 2002 17:33:29 GMT
I suppose that can work.  As for the faith in my colleagues, there is a reason
we do this.  ;)

It isn't my ideal, but your solution so far is the best one I've seen.  The only 
issue with it is that it is negative testing.  Which means that I need to know all
other possible packages that exist to check against them.  Is there a way in ANT to
test all the .class files against a known set of good packages?  Or would I have to
check against the higher level packages only?

Thanks for the input!

Alan

-----Original Message-----
From: Dominique Devienne [mailto:DDevienne@lgc.com]
Sent: Tuesday, April 16, 2002 12:19 PM
To: 'Ant Users List'
Subject: RE: Javac and Sourcepath woes


Hi Alan,

Here's a solution which is not really one... It assumes you don't want to
modify ANT in any way, and maybe have a little more faith in your developer
colleagues ;-)

How about compiling everything together (which might be faster anyway) and
checking separately that the layer boundaries are respected?

The compile or classes target that compiles all the source code is used all
the time by everyone (developer, nightly build, CruiseControl, whatever).
Then nightly, you do compiles you are currently doing (which you fought
should fail, since not including dependencies JARs), but with a different
destination directory for the classes of each layer. You then follow it by
tests (using <condition>) to make sure that classes or packages from higher
level layers are not present in that destination direction. That way, you
use JavaC as a dependency analyzer, and ensure your layering a posteriori.
If you do it often enough, you catch layer-breaking changes early enough.

Hope this helps. --DD

-----Original Message-----
From: Wood, Alan [mailto:a.wood@genaissance.com] 
Sent: Tuesday, April 16, 2002 10:14 AM
To: ant-user@jakarta.apache.org
Subject: Javac and Sourcepath woes

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)

srcdir/
  A/
    A1/
    A2/
  B/
    B1/
    B2/

Now comes the problem.

I specify my build as such for A1:

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

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


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)

Thanks,

Alan

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message