ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <>
Subject RE: javac
Date Tue, 12 Jul 2005 13:40:13 GMT
Phil is right Jean. Independently of splitting the code in subsystems, which
is always a good idea, even if you can't do that you can split the compile
of a single source tree into several passes using regular <javac>. This can
even enforce dependencies of the code compiled by the different passes. The
trick is to reset the sourcepath that <javac> normally sets.

I include here an example for reference. Hope this helps. --DD

  <!-- =====================================================
       Compile the java code from src/ into build/classes
  <target name="-classes">

    <mkdir dir="build/classes/META-INF" />
    <mkdir dir="build/testclasses" />

    <!-- Avoid warning message about memoryMaximumSize being ignored
         when not forking <javac>, and instead specify directly the
         JVM argument only when forking... Convoluted, but works!  -->
    <property name="javac.memoryMaximumSize.true" value="-J-Xmx512m" />
    <property name="javac.memoryMaximumSize.false" value="" />

    <property name="deprecation" value="true" />

    <macrodef name="compile">
      <attribute name="fork" default="false" />
      <attribute name="srcdir" default="src" />
      <attribute name="destdir" default="build/classes" />
      <element name="sources" implicit="true" optional="true" />
        <javac srcdir="@{srcdir}" source="1.4"
               destdir="@{destdir}" sourcepath=""
               deprecation="${deprecation}" debug="true" verbose="false"
               includeAntRuntime="false" fork="@{fork}">
          <!-- equivalent to <javac ... memoryMaximumSize="512m"> -->
          <compilerarg line="${javac.memoryMaximumSize.@{fork}}" />
          <classpath refid="classpath" />

    <!-- compile FOO first, -->
    <compile fork="true">
      <include name="com/acme/foo/**" />
      <include name="com/acme/app/foo/**" />

    <!-- then BAR, -->
      <include name="com/acme/bar/**" />
      <include name="com/acme/app/bar/**" />
      <include name="com/acme/testing/utils/TestAlgo*.java" />

    <!-- then the package-private tests, -->
    <compile srcdir="test" destdir="build/testclasses" />

    <!-- and finally the examples. -->
      <include name="com/acme/examples/**" />


> -----Original Message-----
> From: Phil Weighill Smith []
> Why not simply put two calls to javac in your build script and split the
> source tree in two in the same way that you have in your new task,
> passing one tree to the first call and the other to the second?
> Clearly you need to ensure that the first call compiles "pre-requisite"
> code for the second call and that you should avoid cyclic references
> between the two sets of classes.
> On Tue, 2005-07-12 at 00:12 -0700, Jean Lazarou wrote:
> > We had problem with a (legacy) build from scratch, seems that, because
> we have too many java files to compile, nothing is compiled (both on Linux
> and Windfoos2000).
> >
> > After spending 4 days on that, I decided to split the compilation, I
> created a new task, name "bydir-javac". The task is derived from Javac.
> >
> > Can I publish this? Is it a better way of doing it?

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

View raw message