## 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 `<classesespath>`, 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. The default is "text", the alternative is "xml" | No
fork | Run the tests in a separate VM. | 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). (Ignored if fork is disabled.) | No
jvm | The command used to invoke the Java Virtual Machine, default is 'java'. The command is resolved by java.lang.Runtime.exec(). (Ignored if fork is disabled.) | No, default "java"
dir | The directory to invoke the VM in. (Ignored if fork is disabled) | No
includeruntime | Implicitly add the classes required to run jdepend in forked mode. (Ignored if fork is disabled). Since ant 1.6. | No, default is "no".
classpathref | the classpath to use, given as reference to a PATH defined elsewhere. | No

### 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

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

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

>     <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>

This invokes JDepend in a separate VM 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 classpathref="base.path">
>         <exclude name="java.*>
>         <exclude name="javax.*>
>         <classespath>
>             <pathelement location="build"/>
>         </classespath>
>     </jdepend>

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