You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Lopez, William" <wi...@eds.com> on 2003/05/13 01:19:55 UTC

Depend task question

First, let me apologize for a long e-mail...I'm having difficulty
comprehending the depend task.

This is the scenario:

I have multiple projects (source and class directories) that I want to
include in the depend task because there are cycles (circular references)
amongst the projects. For example:
  DirA (contains more than 1 package) 
  DirB (contains more than 1 package)
  DirC (contains more than 1 package)
  DirD ...  

DirA.package2.class1 extends DirA.package1.class1
DirB.package1.class1 uses DirA.package2.class1
DirC.package1.class1 uses DirB.package1.class1
...something to that effect

I want to include all the classes in these projects in the depend task so
that all the classes related would be deleted and forced to recompile...I
set the 'closure="yes"' to allow indirect relationships. Each source
directory (project) has a corresponding class directory...so the project
hierarchy looks like this (there are more dirs than depicted):

  top_dir
   |
   |_source_dir
   |  |
   |  |_DirA
   |  |
   |  |_DirB
   |  |
   |  |_DirC
   |  |
   |  |_DirD
   |
   |_class_dir
   |  |
   |  |_DirA
   |  |
   |  |_DirB
   |  |
   |  |_DirC
   |  |
   |  |_DirD
   |
   |...other directories

...the Ant doco states the following about the classpath nested element:
The classpath attribute for <depend> is optional. If it is present, depend
will check class dependencies against classes and jars on this classpath.
Any classes which depend on an element from this classpath and which are
older than that element will be deleted. 

...so I figured the following could be done:

      <path id="all-BO-classes">
	    <fileset dir="${bo.build.dir}\DirA" includes="**\*.class" /> 
          <fileset dir="${bo.build.dir}\DirA${Entity}" includes="**\*.class"
/>
          <fileset dir="${bo.build.dir}\DirB" includes="**\*.class" />
          <fileset dir="${bo.build.dir}\DirC${Entity}" includes="**\*.class"
/>
          <fileset dir=... />
      </path>

...then use that path in the task:

    <target name="synchBODirs">
      <depend srcdir="${src.base}" destdir="${bo.build.dir}"
              cache="depcache" closure="yes">
        <include name="**/*.java"/>
        <classpath refid="all-BO-classes"/>
      </depend>
   </target>

...here is where things get muddy for me. 

The srcdir points to the source_dir and destdir to the class_dir in the
hierarchy. The problem I see is that the srcdir points to the
top_dir/source_dir (which includes 15 other directories/projects) and the
destdir points to the class output directories I want which contains 6
directories...the path element defined has a matching directory in the
destdir- one-to-one. My main question is how do I get the scrdir to only
have the 6 directories of source files to match the six in the destdir so no
extraneous classes are added to the dependency charting? 

One note, The project hierarchy cannot be changed because that is the way it
is in PVCS and in WSAD...we used to do the compilation via WSAD but that was
too cumbersome and error prone. I hope this was not too convoluted. All
suggestions are welcome.

Thanks,
-Will