JDepend

Description

Invokes the JDepend parser.

This parser "traverses a set of Java source file directories and generates design quality metrics for each Java package". It allows to "automatically measure the quality of a design in terms of its extensibility, reusability, and maintainability to effectively manage and control package dependencies."

Source file directories are defined by nested <sourcespath>. Class file directories are defined by nested <classespath>. See nested elements.

Optionally, you can also set the outputfile name where the output is stored. By default the task writes its report to the standard output.

The task requires at least the JDepend 1.2 version.

Parameters

Attribute Description Required
outputfile The output file name. If not set, the output is printed on the standard output. No
format The format to write the output in, either text (default) or xml No; the default is text
fork Run the tests in a separate JVM. No; default is off
haltonerror Stop the build process if an error occurs during the jdepend analysis. No; default is off
timeout Cancel the operation if it doesn't finish in the given time (measured in milliseconds). No, ignored if fork is false
jvm The command used to invoke JVM. The command is resolved by java.lang.Runtime.exec(). No; default java, ignored if fork is false
dir The directory to invoke JVM in. No, ignored if fork is false
includeruntime Implicitly add the classes required to run jdepend in forked mode. Since Apache Ant 1.6. No; default is no, ignored if fork is false
classpathref the classpath to use, given as reference to a path defined elsewhere. No

Parameters specified as nested elements

jdepend supports four nested elements: <classpath>, <classespath> and <sourcespath>, that represent path-like structures, and <exclude>.

<sourcespath> is used to define the paths of the source code to analyze, but it is deprecated. With version 2.5 of JDepend, only class files are analyzed. The nested element <classespath> replaces <sourcespath> and is used to define the paths of compiled class code to analyze; the <sourcespath> variable is still available in case you are using an earlier version of JDepend. The <exclude> element can be used to set packages to ignore (requires JDepend 2.5 or above).

Examples

Invoke JDepend on the build directory, writing the output on the standard output. The classpath is defined using a reference.

<jdepend classpathref="base.path">
    <classespath>
        <pathelement location="build"/>
    </classespath>
</jdepend>

This invoke JDepend in a separate JVM on the src and testsrc directories, writing the output to the docs/jdepend.xml file in XML format. The classpath is defined using nested elements.

<jdepend outputfile="docs/jdepend.xml" fork="yes" format="xml">
    <sourcespath>
        <pathelement location="src"/>
    </sourcespath>
    <classpath>
        <pathelement location="classes"/>
        <pathelement location="lib/jdepend.jar"/>
    </classpath>
</jdepend>

Invoke JDepend with the build directory as the base for class files to analyze, and ignore all classes in the java.* and javax.* packages.

<jdepend classpathref="base.path">
    <exclude name="java.*>
    <exclude name="javax.*>
    <classespath>
        <pathelement location="build"/>
    </classespath>
</jdepend>