org.apache.tools.ant.taskdefs.optional.jdepend

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

Nested Class Summary
static classJDependTask.FormatAttribute
A class for the enumerated attribute format, values are xml and text.
Method Summary
PathcreateClassespath()
Adds a path to class code to analyze.
PathcreateClasspath()
Adds a path to the classpath.
PatternSet.NameEntrycreateExclude()
add a name entry on the exclude list
Commandline.ArgumentcreateJvmarg(CommandlineJava commandline)
Create a new JVM argument.
PathcreateSourcespath()
Adds a path to source code to analyze.
protected ExecuteWatchdogcreateWatchdog()
voidexecute()
execute the task
intexecuteAsForked(CommandlineJava commandline, ExecuteWatchdog watchdog)
Execute the task by forking a new JVM.
intexecuteInVM(CommandlineJava commandline)
Execute inside VM.
PathgetClassespath()
Gets the classespath.
PathgetClasspath()
Gets the classpath to be used for this compilation.
FilegetDir()
PatternSetgetExcludes()
booleangetFork()
booleangetHaltonerror()
FilegetOutputFile()
PathgetSourcespath()
Gets the sourcepath.
LonggetTimeout()
voidsetClasspath(Path classpath)
Set the classpath to be used for this compilation.
voidsetClasspathRef(Reference r)
Adds a reference to a classpath defined elsewhere.
voidsetDir(File dir)
The directory to invoke the VM in.
voidsetFork(boolean value)
If true, forks into a new JVM.
voidsetFormat(JDependTask.FormatAttribute ea)
The format to write the output in, "xml" or "text".
voidsetHaltonerror(boolean haltonerror)
Whether or not to halt on failure.
voidsetIncluderuntime(boolean b)
If true, include jdepend.jar in the forked VM.
voidsetJvm(String value)
The command used to invoke a forked Java Virtual Machine.
voidsetOutputFile(File outputFile)
The output file name.
voidsetTimeout(Long value)
Set the timeout value (in milliseconds).

Method Detail

createClassespath

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

Returns: a classes path

createClasspath

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

Returns: a classpath

createExclude

public PatternSet.NameEntry createExclude()
add a name entry on the exclude list

Returns: a pattern for the excludes

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

createSourcespath

public Path createSourcespath()

Deprecated:

Adds a path to source code to analyze.

Returns: a source path

createWatchdog

protected ExecuteWatchdog createWatchdog()

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

Throws: BuildException in case of error

execute

public void execute()
execute the task

Throws: BuildException if an error occurs

executeAsForked

public int executeAsForked(CommandlineJava commandline, ExecuteWatchdog watchdog)
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

executeInVM

public int executeInVM(CommandlineJava commandline)
Execute inside VM.

Parameters: commandline the command line

Returns: the return value of the mvm

Throws: BuildException if an error occurs

getClassespath

public Path getClassespath()
Gets the classespath.

Returns: the classes path

getClasspath

public Path getClasspath()
Gets the classpath to be used for this compilation.

Returns: the class path used for compilation

getDir

public File getDir()

Returns: the dir attribute

getExcludes

public PatternSet getExcludes()

Returns: the excludes patterns

getFork

public boolean getFork()

Returns: the value of the fork attribute

getHaltonerror

public boolean getHaltonerror()

Returns: the value of the haltonerror attribute

getOutputFile

public File getOutputFile()

Returns: the output file name

getSourcespath

public Path getSourcespath()

Deprecated:

Gets the sourcepath.

Returns: the sources path

getTimeout

public Long getTimeout()

Returns: the timeout value

setClasspath

public void setClasspath(Path classpath)
Set the classpath to be used for this compilation.

Parameters: classpath a class path to be used

setClasspathRef

public void setClasspathRef(Reference r)
Adds a reference to a classpath defined elsewhere.

Parameters: r a classpath reference

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

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

setFormat

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

Parameters: ea xml or text

setHaltonerror

public void setHaltonerror(boolean haltonerror)
Whether or not to halt on failure. Default: false.

Parameters: haltonerror the value to set

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

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

setOutputFile

public void setOutputFile(File outputFile)
The output file name.

Parameters: outputFile the output file name

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

Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.