简体   繁体   中英

Resolving source-code dependencies

I'd like to generate a list of Java class dependencies, similar to Ant's depend task, without the limitations listed at the bottom of the aforementioned page.

Are there any decent source-code dependency analyzers for Java? I've tried writing my own but resolving references is very complicated.

UPDATE : I'd like to reuse the algorithm in my open-source project. Please provide libraries which are open-source compatible.

One of the best tools I've found for this job is Jar Analyzer .

From the homepage

JarAnalyzer is a dependency management utility for jar files. It's primary purpose is to traverse through a directory, parse each of the jar files in that directory, and identify the dependencies between the jar files. The output is an xml file representing the PhysicalDependencies between the jar files.

Our DMS Software Reengineering Toolkit and its Java Front End can parse and name-resolve Java through 1.6 from just the source code. (It parses 1.7 but doesn't name resolve some very dark corners, to be implemented Very Soon). It will use class files if you allow it. This provides a full AST and symbol tables. The DMS machinery will let you visit/inspect the ASTs and symbol tables.

From the symbol table data and the specific list of files of interest, you could compute the dependencies only using source code.

Yes, writing a name resolver is complex. Our team has more than a year invested in it, and still more to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM