JDependTask (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.taskdefs.optional.jdepend, class: JDependTask

# Class JDependTask

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

All Implemented Interfaces:
  `Cloneable`

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 https://github.com/clarkware/jdepend. The current implementation spawn a new Java VM.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `JDependTask.FormatAttribute`
  A class for the enumerated attribute format, values are xml and text.

- ## Field Summary

  ### Fields inherited from class Task

  `target, taskName, taskType, wrapper`
  Modifier and Type
  Field
  Description
  `protected Target`
  `target`
  Deprecated.
  since 1.6.x.
  `protected String`
  `taskName`
  Deprecated.
  since 1.6.x.
  `protected String`
  `taskType`
  Deprecated.
  since 1.6.x.
  `protected RuntimeConfigurable`
  `wrapper`
  Deprecated.
  since 1.6.x.

  ### Fields inherited from class ProjectComponent

  `description, location, project`
  Modifier and Type
  Field
  Description
  `protected String`
  `description`
  Deprecated.
  since 1.6.x.
  `protected Location`
  `location`
  Deprecated.
  since 1.6.x.
  `protected Project`
  `project`
  Deprecated.
  since 1.6.x.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JDependTask()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Path`
  `createClassespath()`
  Adds a path to class code to analyze.
  `Path`
  `createClasspath()`
  Adds a path to the classpath.
  `PatternSet.NameEntry`
  `createExclude()`
  add a name entry on the exclude list
  `Commandline.Argument`
  `createJvmarg(CommandlineJava commandline)`
  Create a new JVM argument.
  `Path`
  `createSourcespath()`
  Deprecated.
  since 1.6.x.
  `protected ExecuteWatchdog`
  `createWatchdog()`
  `void`
  `execute()`
  execute the task
  `int`
  `executeAsForked(CommandlineJava commandline, ExecuteWatchdog watchdog)`
  Execute the task by forking a new JVM.
  `int`
  `executeInVM(CommandlineJava commandline)`
  Execute inside VM.
  `Path`
  `getClassespath()`
  Gets the classespath.
  `Path`
  `getClasspath()`
  Gets the classpath to be used for this compilation.
  `File`
  `getDir()`
  `PatternSet`
  `getExcludes()`
  `boolean`
  `getFork()`
  `boolean`
  `getHaltonerror()`
  `File`
  `getOutputFile()`
  `Path`
  `getSourcespath()`
  Deprecated.
  since 1.6.x.
  `Long`
  `getTimeout()`
  `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(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 haltonerror)`
  Whether or not to halt on failure.
  `void`
  `setIncluderuntime(boolean b)`
  If true, include jdepend.jar in the forked VM.
  `void`
  `setJvm(String value)`
  The command used to invoke a forked Java Virtual Machine.
  `void`
  `setOutputFile(File outputFile)`
  The output file name.
  `void`
  `setTimeout(Long value)`
  Set the timeout value (in milliseconds).

  ### Methods inherited from class Task

  `bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType`
  Modifier and Type
  Method
  Description
  `final void`
  `bindToOwner(Task owner)`
  Bind a task to another; use this when configuring a newly created task to do work on behalf of another.
  `Target`
  `getOwningTarget()`
  Returns the container target of this task.
  `RuntimeConfigurable`
  `getRuntimeConfigurableWrapper()`
  Returns the wrapper used for runtime configuration.
  `String`
  `getTaskName()`
  Returns the name to use in logging messages.
  `String`
  `getTaskType()`
  Return the type of task.
  `protected RuntimeConfigurable`
  `getWrapper()`
  Return the runtime configurable structure for this task.
  `protected void`
  `handleErrorFlush(String output)`
  Handles an error line by logging it with the WARN priority.
  `protected void`
  `handleErrorOutput(String output)`
  Handles an error output by logging it with the WARN priority.
  `protected void`
  `handleFlush(String output)`
  Handles output by logging it with the INFO priority.
  `protected int`
  `handleInput(byte[] buffer, int offset, int length)`
  Handle an input request by this task.
  `protected void`
  `handleOutput(String output)`
  Handles output by logging it with the INFO priority.
  `void`
  `init()`
  Called by the project to let the task initialize properly.
  `protected final boolean`
  `isInvalid()`
  Has this task been marked invalid?
  `void`
  `log(String msg)`
  Logs a message with the default (INFO) priority.
  `void`
  `log(String msg, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `log(String msg, Throwable t, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `log(Throwable t, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `maybeConfigure()`
  Configures this task - if it hasn't been done already.
  `final void`
  `perform()`
  Performs this task if it's still valid, or gets a replacement version and performs that otherwise.
  `void`
  `reconfigure()`
  Force the task to be reconfigured from its RuntimeConfigurable.
  `void`
  `setOwningTarget(Target target)`
  Sets the target container of this task.
  `void`
  `setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper)`
  Sets the wrapper to be used for runtime configuration.
  `void`
  `setTaskName(String name)`
  Sets the name to use in logging messages.
  `void`
  `setTaskType(String type)`
  Sets the name with which the task has been invoked.

  ### Methods inherited from class ProjectComponent

  `clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject`
  Modifier and Type
  Method
  Description
  `Object`
  `clone()`
  `String`
  `getDescription()`
  Returns the description of the current action.
  `Location`
  `getLocation()`
  Returns the file/location where this task was defined.
  `Project`
  `getProject()`
  Returns the project to which this component belongs.
  `void`
  `setDescription(String desc)`
  Sets a description of the current action.
  `void`
  `setLocation(Location location)`
  Sets the file/location where this task was defined.
  `void`
  `setProject(Project project)`
  Sets the project object of this component.

  ### Methods inherited from class Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### JDependTask

    public JDependTask()

- ## Method Details

  - ### setIncluderuntime

    public void setIncluderuntime(boolean b)
    If true, include jdepend.jar in the forked VM.
    Parameters:
      `b` - include ant run time yes or no
    Since:
      Ant 1.6

  - ### setTimeout

    public void setTimeout(Long value)
    Set the timeout value (in milliseconds).

    If the operation is running for more than this value, the jdepend will be canceled. (works only when in 'fork' mode).

    Parameters:
      `value` - the maximum time (in milliseconds) allowed before declaring the test as 'timed-out'
    See Also:
      - `setFork(boolean)`

  - ### getTimeout

    public Long getTimeout()
    Returns:
      the timeout value

  - ### setOutputFile

    public void setOutputFile(File outputFile)
    The output file name.
    Parameters:
      `outputFile` - the output file name

  - ### getOutputFile

    public File getOutputFile()
    Returns:
      the output file name

  - ### setHaltonerror

    public void setHaltonerror(boolean haltonerror)
    Whether or not to halt on failure. Default: false.
    Parameters:
      `haltonerror` - the value to set

  - ### getHaltonerror

    public boolean getHaltonerror()
    Returns:
      the value of the haltonerror attribute

  - ### 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()
    Returns:
      the value of the fork attribute

  - ### setJvm

    public void setJvm(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

    @Deprecated public Path createSourcespath()
    Deprecated.
    since 1.6.x.
    Adds a path to source code to analyze.
    Returns:
      a source path

  - ### getSourcespath

    @Deprecated public Path getSourcespath()
    Deprecated.
    since 1.6.x.
    Gets the sourcepath.
    Returns:
      the sources path

  - ### createClassespath

    public Path createClassespath()
    Adds a path to class code to analyze.
    Returns:
      a classes path

  - ### getClassespath

    public Path getClassespath()
    Gets the classespath.
    Returns:
      the classes path

  - ### setDir

    public void setDir(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 File getDir()
    Returns:
      the dir attribute

  - ### setClasspath

    public void setClasspath(Path classpath)
    Set the classpath to be used for this compilation.
    Parameters:
      `classpath` - a class path to be used

  - ### getClasspath

    public Path getClasspath()
    Gets the classpath to be used for this compilation.
    Returns:
      the class path used for compilation

  - ### createClasspath

    public Path createClasspath()
    Adds a path to the classpath.
    Returns:
      a classpath

  - ### createJvmarg

    public Commandline.Argument createJvmarg(CommandlineJava commandline)
    Create a new JVM argument. Ignored if no JVM is forked.
    Parameters:
      `commandline` - the commandline to create the argument on
    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.
    Parameters:
      `r` - a classpath reference

  - ### createExclude

    public PatternSet.NameEntry createExclude()
    add a name entry on the exclude list
    Returns:
      a pattern for the excludes

  - ### getExcludes

    public PatternSet getExcludes()
    Returns:
      the excludes patterns

  - ### setFormat

    public void setFormat(JDependTask.FormatAttribute ea)
    The format to write the output in, "xml" or "text".
    Parameters:
      `ea` - xml or text

  - ### execute

    public void execute() throws BuildException
    execute the task
    Overrides:
      `execute` in class `Task`
    Throws:
      `BuildException` - if an error occurs

  - ### executeInVM

    public int executeInVM(CommandlineJava commandline) throws BuildException
    Execute inside VM.
    Parameters:
      `commandline` - the command line
    Returns:
      the return value of the mvm
    Throws:
      `BuildException` - if an error occurs

  - ### 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:
      `commandline` - the commandline for forked jvm
      `watchdog` - the watchdog in charge of cancelling the test if it exceeds a certain amount of time. Can be `null`.
    Returns:
      the result of running the jdepend
    Throws:
      `BuildException` - in case of error

  - ### createWatchdog

    protected ExecuteWatchdog createWatchdog() throws BuildException
    Returns:
      `null` if there is a timeout value, otherwise the watchdog instance.
    Throws:
      `BuildException` - in case of error