DependencyExtractor

Description

Takes a JAR and computes dependencies between packages, classes, and features (methods and attributes). The result is an XML document containing all the dependencies. You can use the various XXXToText and XXXToHTML XSL transformations to render the graph as text or HTML for human reading.

Refer to the Reporting section of the manual for an explanation of the various filter attributes. Basically, filtering refers to the selection of links to or from the classes and methods under extraction.

In practical terms, you filter in or out the dependencies stemming (whether inbound or outbound) from the scoped nodes.

The filterexcludes attribute is where you typically filter out large swaths of links that you do not want in the report, such as "/^java.*/,/^org.*/".

The normal output is the resulting dependency graph, rendered as text.

With the xml attribute, it converts the entire dependency graph into an XML document that follows the dependencies DTD.

Parameters

Attribute Description Required
destfile where to write the output. If the file does not exists, it is created. If it already exists, its content is overwritten. Yes
filterincludes the name of a package, class, or feature at the other end of the dependency must match the regular expressions for the dependency to be included in the results. No
filterexcludes the name of a package, class, or feature at the other end of the dependency must NOT match the regular expressions for the dependency to be included in the results. No
packagefilter show dependencies to and/or from packages. No
packagefilterincludes the name of a package at the other end of the dependency must match the regular expressions for the dependency to be included in the results. No
packagefilterexcludes the name of a package at the other end of the dependency must NOT match the regular expressions for the dependency to be included in the results. No
classfilter show dependencies to and/or from classes. No
classfilterincludes the name of a class at the other end of the dependency must match the regular expressions for the dependency to be included in the results. No
classfilterexcludes the name of a class at the other end of the dependency must NOT match the regular expressions for the dependency to be included in the results. No
featurefilter show dependencies to and/or from features. No
featurefilterincludes the name of a feature at the other end of the dependency must match the regular expressions for the dependency to be included in the results. No
featurefilterexcludes the name of a feature at the other end of the dependency must NOT match the regular expressions for the dependency to be included in the results. No
filterincludeslist the name of a package, class, or feature at the other end of the dependency must match an entry in the named files for the dependency to be included in the results. No
filterexcludeslist the name of a package, class, or feature at the other end of the dependency must NOT match any of the entries in the named files for the dependency to be included in the results. No
xml writes the dependency graph as an XML document with the dependencies DTD. No
encoding encoding used for the XML output document. Only useful with xml. No
dtdprefix prefix of the DTD URL for the XML output document. Only useful with xml. No
indenttext used for each indentation level in textual and XML output. No
minimize minimizes the dependency graph before outputing it. No
maximize maximizes the dependency graph before outputing it. No

Nested elements

path

Use nested path elements to specify file names of JAR files, Zip files, and .class files for the tool to read. You can also give directory names, the tool will search it for .class files and read them. It is a path-like structures.

filterincludeslist

<dependencyextractor>'s filterincludeslist attribute is a path-like structures and can also be set via a nested <src> element.

filterexcludeslist

<dependencyextractor>'s filterexcludeslist attribute is a path-like structures and can also be set via a nested <src> element.

Examples

To scan the current directory and its subdirectories for .class files to analyze and save the resulting dependency graph to df.xml:

  <dependencyextractor destfile="df.xml" xml="yes">
    <path>
      <pathelement location="."/>
    </path>
  </dependencyextractor>

To scan DependencyFinder.jar and rt.jar for .class files to analyze and save the resulting dependency graph to df.xml:

  <dependencyextractor destfile="df.xml" xml="yes">
    <path>
      <pathelement location="DependencyFinder.jar"/>
      <pathelement location="rt.jar"/>
    </path>
  </dependencyextractor>

To scan DependencyFinder.jar and rt.jar for .class files to analyze and save the resulting dependency graph to df.xml without any dependencies on java.*:

  <dependencyextractor destfile="df.xml" xml="yes"
                       filterexcludes="/^java\./">
    <path>
      <pathelement location="DependencyFinder.jar"/>
      <pathelement location="rt.jar"/>
    </path>
  </dependencyextractor>

To scan DependencyFinder.jar and rt.jar for .class files to analyze and save the resulting dependency graph to df.xml, after having minimized it:

  <dependencyextractor destfile="df.xml" xml="yes" minimize="yes">
    <path>
      <pathelement location="DependencyFinder.jar"/>
      <pathelement location="rt.jar"/>
    </path>
  </dependencyextractor>

To scan the current directory and its subdirectories for .class files to analyze and save the resulting dependency graph to df.xml, and then convert it to HTML:

  <dependencyextractor destfile="df.xml" xml="yes">
    <path>
      <pathelement location="."/>
    </path>
  </dependencyextractor>
  <xslt style="${dependencyfinder.home}/etc/DependenciesToHTML.xsl"
        in="df.xml"
        out="df.html"/>

Copyright © 2001-2023 Jean Tessier. All rights reserved.