![]()
|
DependA task to manage Java class file dependencies.DescriptionThe depend task works by determining which classes are out of date with respect to their source and then removing the class files of any other classes which depend on the out-of-date classes. To determine the class dependencies, the depend task analyses the class files of all class files passed to it. Depend does not parse your source code in any way but relies upon the class references encoded into the class files by the compiler. This is generally faster than parsing the Java source. To learn more about how this information is obtained from the class files, please refer to the Java Virtual Machine Specification Since a class' dependencies only change when the class itself changes, the depend task is able to cache dependency information. Only those class files which have changed will have their dependency information re-analysed. Note that if you change a class' dependencies by changing the source, it will be recompiled anyway. You can examine the dependency files created to understand the dependencies of your classes. Please do not rely, however, on the format of the information, as it may change in a later release. Once depend discovers all of the class dependencies, it "inverts" this relation to determine, for each class, which other classes are dependent upon it. This "affects" list is used to discover which classes are invalidated by the out of date class. The class files of the invalidated classes are removed, triggering the compilation of the affected classes. The depend task supports an attribute, "closure" which controls whether depend will only consider direct class-class relationships or whether it will also consider transitive, indirect relationships. For example, say there are three classes, A, which depends on B, which in-turn depend on C. Now say that class C is out of date. Without closure, only class B would be removed by depend. With closure set, class A would also be removed. Normally direct relationships are sufficient - it is unusual for a class to depend on another without having a direct relationship. With closure set, you will notice that depend typically removes far more class files. The classpath attribute for PerformanceThe performance of the depend task is dependent on a number of factors such as class relationship complexity and how many class files are out of date. The decision about whether it is cheaper to just recompile all classes or to use the depend task will depend on the size of your project and how interrelated your classes are. LimitationsThere are some source dependencies which depend will not detect.
public final class Constants { public final static boolean DEBUG=false; }will not be picked up by other classes. Parameters
Parameters specified as nested elementsThe Additionally,
this task forms an implicit
FileSet
and supports all attributes of
Examples<depend srcdir="${java.dir}" destdir="${build.classes}" cache="depcache" closure="yes"/> removes any classes in the <depend srcdir="${java.dir}" destdir="${build.classes}" cache="depcache" closure="yes"> <include name="**/*.java"/> <excludesfile name="${java.dir}/build_excludes"/> </depend> does the same as the previous example, but explicitly includes all
Copyright © 2001-2002 Apache Software Foundation. All rights Reserved. |