## org.apache.tools.ant.taskdefs.optional.jdepend
Class JDependTask

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              org.apache.tools.ant.taskdefs.optional.jdepend.JDependTask

public class JDependTask
extends Task

Runs JDepend tests.

JDepend is a tool to generate design quality metrics for each Java package. It has been initially created by Mike Clark. JDepend can be found at http://www.clarkware.com/software/JDepend.html. The current implementation spawn a new Java VM.

Author:
  Jerome Lacoste, Rob Oxspring

Nested Class Summary
`static class` `JDependTask.FormatAttribute`

Field Summary

Fields inherited from class org.apache.tools.ant.Task
`description, location, target, taskName, taskType, wrapper`

Fields inherited from class org.apache.tools.ant.ProjectComponent
`project`

Constructor Summary
`JDependTask()`

Method Summary
`Path` `createClasspath()` Adds a path to the classpath.
`Commandline.Argument` `createJvmarg(CommandlineJava commandline)` Create a new JVM argument.
`Path` `createSourcespath()` Adds a path to source code to analyze.
`protected ExecuteWatchdog` `createWatchdog()`
`void` `execute()` Called by the project to let the task do its work.
`int` `executeAsForked(CommandlineJava commandline, ExecuteWatchdog watchdog)` Execute the task by forking a new JVM.
`int` `executeInVM(CommandlineJava commandline)` Execute inside VM.
`Path` `getClasspath()` Gets the classpath to be used for this compilation.
`java.io.File` `getDir()`
`boolean` `getFork()`
`boolean` `getHaltonerror()`
`java.io.File` `getOutputFile()`
`Path` `getSourcespath()` Gets the sourcepath.
`void` `setClasspath(Path classpath)` Set the classpath to be used for this compilation.
`void` `setClasspathRef(Reference r)` Adds a reference to a classpath defined elsewhere.
`void` `setDir(java.io.File dir)` The directory to invoke the VM in.
`void` `setFork(boolean value)` If true, forks into a new JVM.
`void` `setFormat(JDependTask.FormatAttribute ea)` The format to write the output in, "xml" or "text".
`void` `setHaltonerror(boolean value)` Whether or not to halt on failure.
`void` `setJvm(java.lang.String value)` The command used to invoke a forked Java Virtual Machine.
`void` `setOutputFile(java.io.File outputFile)` The output file name.

Methods inherited from class org.apache.tools.ant.Task
`getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName`

Methods inherited from class org.apache.tools.ant.ProjectComponent
`getProject, setProject`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JDependTask

    public JDependTask()

Method Detail

### setOutputFile

    public void setOutputFile(java.io.File outputFile)

  The output file name.

  Parameters:
    `outputFile` -

### getOutputFile

    public java.io.File getOutputFile()

### setHaltonerror

    public void setHaltonerror(boolean value)

  Whether or not to halt on failure. Default: false.

### getHaltonerror

    public boolean getHaltonerror()

### setFork

    public void setFork(boolean value)

  If true, forks into a new JVM. Default: false.

  Parameters:
    `value` - `true` if a JVM should be forked, otherwise `false```

### getFork

    public boolean getFork()

### setJvm

    public void setJvm(java.lang.String value)

  The command used to invoke a forked Java Virtual Machine. Default is `java`. Ignored if no JVM is forked.

  Parameters:
    `value` - the new VM to use instead of `java`
  See Also:
    `setFork(boolean)`

### createSourcespath

    public Path createSourcespath()

  Adds a path to source code to analyze.

### getSourcespath

    public Path getSourcespath()

  Gets the sourcepath.

### setDir

    public void setDir(java.io.File dir)

  The directory to invoke the VM in. Ignored if no JVM is forked.

  Parameters:
    `dir` - the directory to invoke the JVM from.
  See Also:
    `setFork(boolean)`

### getDir

    public java.io.File getDir()

### setClasspath

    public void setClasspath(Path classpath)

  Set the classpath to be used for this compilation.

### getClasspath

    public Path getClasspath()

  Gets the classpath to be used for this compilation.

### createClasspath

    public Path createClasspath()

  Adds a path to the classpath.

### createJvmarg

    public Commandline.Argument createJvmarg(CommandlineJava commandline)

  Create a new JVM argument. Ignored if no JVM is forked.

  Returns:
    create a new JVM argument so that any argument can be passed to the JVM.
  See Also:
    `setFork(boolean)`

### setClasspathRef

    public void setClasspathRef(Reference r)

  Adds a reference to a classpath defined elsewhere.

### setFormat

    public void setFormat(JDependTask.FormatAttribute ea)

  The format to write the output in, "xml" or "text".

  Parameters:
    `ea` -

### execute

    public void execute()
                 throws BuildException

  Description copied from class: `Task`
  Called by the project to let the task do its work. This method may be called more than once, if the task is invoked more than once. For example, if target1 and target2 both depend on target3, then running "ant target1 target2" will run all tasks in target3 twice.

  Overrides:
    `execute` in class `Task`
  Throws:
    `BuildException` - if something goes wrong with the build

### executeInVM

    public int executeInVM(CommandlineJava commandline)
                    throws BuildException

  Execute inside VM.

  Throws:
    `BuildException`

### executeAsForked

    public int executeAsForked(CommandlineJava commandline,
                               ExecuteWatchdog watchdog)
                        throws BuildException

  Execute the task by forking a new JVM. The command will block until it finishes. To know if the process was destroyed or not, use the `killedProcess()` method of the watchdog class.

  Parameters:
    `watchdog` - the watchdog in charge of cancelling the test if it exceeds a certain amount of time. Can be `null`, in this case the test could probably hang forever.
  Throws:
    `BuildException`

### createWatchdog

    protected ExecuteWatchdog createWatchdog()
                                      throws BuildException

  Returns:
    `null` if there is a timeout value, otherwise the watchdog instance.
  Throws:
    `BuildException`

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.