ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bela Ban <b...@nms.fnc.fujitsu.com>
Subject Mapping src to dest files in Javac
Date Tue, 18 Jun 2002 17:07:55 GMT
I have read through the FAQs and mailing list archives, but haven't been
able to find an answer to the problem below.

It boils down to (a) whether mapper elements now allowed / implemented
inside FileSets (proposed by Stefan Bodewig) and (b) whether <javac>
allows for nested <mapper> elements.

I have a directory structure as follows (JG=/home/bela/JavaGroups-2.0):

  $JG/src: (source files)
  e.g. $JG/src/org/javagroups/...

  and

  $JG/classes (class files)
  e.g. $JG/classes/org/javagroups/...

  I have a build.xml file in $JG.

  Now my problem: I want to go into any directory
  (e.g. $JG/org/javagroups/util/) and invoke 'ant -find build.xml
compile',
  which should use the build.xml file in $JG and recompile ONLY THE
  FILES IN THE CURRENT DIRECTORY WHICH CHANGED.

  So when I set destdir in <Javac> to $JG/classes and srcdir to
  $JG/src, I want to say includes="*.java", so that only the Java
  files in the current directory are included.

  Let's say I have A.java and B.java in
  $JG/src/org/javagroups/util. The <javac> task now compares these
  files against $JG/classes: it checks for $JG/classes/A.class and
  $JG/classes/B.class instead of
  $JG/classes/org/javagroups/util/A.class and
  $JG/classes/org/javagroups/util/B.class. Therefore it will not find
  the class files and always recompile A.java and B.java, which is not
needed.

  My solution was to use includes="${user.dir}/*.java" (which is
  $JG/src/org/javagroups/util/*.java) and write a custom task which
  removed $JG/src from this string and added the resulting string to
  the properties, so that the include string would
  be org/javagroups/util/*.java, which - compared against
  $JG/classes/org/javagroups/util - yields the correct result.

  However, this is a kludge, and I think there must be a better
  solution.

  I was thinking if <mapper> elements were allowed inside fileset (or
  directly inside <javac>), then we could specify the following:

   <javac srcdir="${JG}/src"
       destdir="${JG}/classes">
       <include dir="${user.dir}">
           <mapper id="bla" type="regexp" from="*org/javagroups*"
to="org/javagroups\2"/>
       </include>
       <classpath refid="netsmart.classpath"/>
   </javac>

  Anyone ?

--
Bela Ban
Fujitsu Network Communications
(408) 895-1732


Mime
View raw message