On Mon, 18 Aug 2003, Stefan Bodewig <[EMAIL PROTECTED]> wrote:

> <java> or <javac>?
<javac>!

> What would the mapper in <javac> be supposed to do?
There is a GlobPatternMapper in the javac-taskdef which is fixed to map
*.java-files to corresponding *.class-files. This is the reason why the
source directory structure and the destination directory structure must
match, which is usually no problem and what is expected by the
java-compiler as well.

Nevertheless there are situations in which this not the best case. I think
about a source layout, where different packages are in different
directories like this:

      src
      +--team1
      !  +--com
      !     +--example
      !        +--pack1
      !           +--Class1.java
      !           +--Class2.java
      +--team2
         +--com
            +--example
               +--pack2
                  +--ClassA.java
                  +--ClassB.java

But all packages should be compiled into a common directory like this:

      build
      +--com
         +--example
            +--pack1
            !  +--Class1.class
            !  +--Class2.class
            +--pack2
               +--ClassA.class
               +--ClassB.class

The following task would compile all sources:

 <javac srcdir="src"
        destdir="build">
 </javac>

But it would not be able to track unchanged *.java-files and does a
recompile each time ant is invoked.

Todays solution is either calling javac twice or copying all *.java-files
to a common directory before calling javac.

I guess it's faster and easier just to tell javac, how to find matching
sources and output like this:

 <javac srcdir="src"
        destdir="build">
   <mapper type="regexp" from="[^/]+/(.*)\.java" to="\1.class"/>
 </javac>

Of course <mapper type="glob" from"*.java" to="*.class"/> will be the
default.

Do you think this makes sense?

Ulf

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to