Maven

Maven 工具: mvn dependency:tree

在项目目录执行 mvn dependency:tree :

https://github.com/che-samples/che-ide-server-extension 项目的子项目 plugins/plugin-serverservice/plugin-serverservice-ide 的依赖如下:

[INFO] Scanning for projects...
[INFO] 
[INFO] ----------< org.eclipse.che.sample:plugin-serverservice-ide >-----------
[INFO] Building Plugin ServerService :: Plugin :: IDE 6.16.0
[INFO] ------------------------------[ gwt-lib ]-------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:3.0.1:tree (default-cli) @ plugin-serverservice-ide ---
[INFO] org.eclipse.che.sample:plugin-serverservice-ide:gwt-lib:6.16.0
[INFO] +- com.google.inject:guice:jar:4.2.2:compile
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- javax.inject:javax.inject:jar:1:compile
[INFO] +- org.eclipse.che.core:che-core-commons-gwt:jar:6.16.0:compile
[INFO] |  +- com.google.code.findbugs:jsr305:jar:3.0.1:compile

... ...

[INFO] |  +- org.eclipse.che.core:che-core-api-core:jar:6.16.0:compile
[INFO] |  |  +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] |  |  +- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
[INFO] |  |  +- net.java.dev.jna:jna:jar:4.1.0:compile
[INFO] |  |  +- org.eclipse.che.core:che-core-commons-json:jar:6.16.0:compile
[INFO] |  |  +- org.eclipse.che.core:che-core-commons-lang:jar:6.16.0:compile
[INFO] |  |  |  \- org.apache.commons:commons-compress:jar:1.18:compile
[INFO] |  |  +- org.eclipse.che.core:che-core-commons-schedule:jar:6.16.0:compile
[INFO] |  |  |  \- org.eclipse.che.core:che-core-commons-inject:jar:6.16.0:compile
[INFO] |  |  |     +- com.google.inject.extensions:guice-servlet:jar:4.2.2:compile
[INFO] |  |  |     \- org.everrest:everrest-integration-guice:jar:1.13.5:compile
[INFO] |  |  +- org.everrest:everrest-core:jar:1.13.5:compile
[INFO] |  |  |  +- commons-fileupload:commons-fileupload:jar:1.3.3:compile
[INFO] |  |  |  +- javax.mail:mail:jar:1.4.4:compile
[INFO] |  |  |  \- commons-io:commons-io:jar:2.6:compile
[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.24:compile
[INFO] |  +- org.eclipse.che.core:che-core-commons-annotations:jar:6.16.0:compile
[INFO] |  +- org.vectomatic:lib-gwt-svg:jar:0.5.12:compile
[INFO] |  \- org.webjars:requirejs:jar:2.1.15:runtime
[INFO] +- org.eclipse.che.core:che-core-ide-api:jar:6.16.0:compile
[INFO] |  +- com.google.inject.extensions:guice-assistedinject:jar:4.2.2:compile
[INFO] |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  +- org.eclipse.che:che-exec-agent-shared:jar:6.16.0:compile

... ...

[INFO] |  +- org.eclipse.che.core:che-core-api-user-shared:jar:sources:6.16.0:compile
[INFO] |  +- org.eclipse.che.core:che-core-api-workspace-shared:jar:6.16.0:compile
[INFO] |  \- org.eclipse.che.core:che-core-api-workspace-shared:jar:sources:6.16.0:compile
[INFO] \- com.google.gwt:gwt-user:jar:2.8.2:provided
[INFO]    +- com.google.jsinterop:jsinterop-annotations:jar:1.0.2:provided
[INFO]    +- com.google.jsinterop:jsinterop-annotations:jar:sources:1.0.2:provided
[INFO]    +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO]    \- org.w3c.css:sac:jar:1.3:provided
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.313 s
[INFO] Finished at: 2019-08-01T10:40:52+08:00
[INFO] ------------------------------------------------------------------------

Eclipse 可视化界面

打开 pom.xml, Eclipse 提供多个视图, 点击下面的 Dependency Hierarchy 视图:
在这里插入图片描述点击左栏中的包时会在右栏高亮对应包, 在右栏点击包会在左栏高亮所有依赖与该包的包.

在这里插入图片描述

Apache Maven Dependency Plugin

在项目的 pom.xml 下添加如下 plugin:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.2</version>
        </plugin>
    </plugins>
</build>  

然后

mvn dependency:tree -DoutputType=graphml -DoutputFile=dependency.graphml

目录下生成 dependency.graphml .

然后下载 yEd , 或者使用 yEd 的在线版本 以生成查看导出依赖图.

同样是 plugin-serverservice-ide 的依赖↓:

在这里插入图片描述

C / C++

GCC 工具: gcc -M <file>.cpp

对于 C++ 文件:

#include <iostream>
#include "lib1.h"

... ...

gcc -M <file>.cpp : 显示该文件的所有依赖.

main.o: main.cpp /usr/include/stdc-predef.h /usr/include/c++/5/iostream \
 /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h \
 /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h \
 /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
 /usr/include/x86_64-linux-gnu/bits/wordsize.h \

... ...

 /usr/include/c++/5/bits/locale_facets.tcc \
 /usr/include/c++/5/bits/basic_ios.tcc \
 /usr/include/c++/5/bits/ostream.tcc /usr/include/c++/5/istream \
 /usr/include/c++/5/bits/istream.tcc lib1.h


gcc -MM <file>.cpp : 显示该文件的所有依赖 (不包括系统依赖的头文件).

main.o: main.cpp lib1.h

CMake: Graphviz

需要 Graphviz 工具: sudo apt-get install graphviz .

# 当前在项目 (CMakeLists.txt) 目录
cd build/
cmake .. --graphviz=<graph>.dot
dot <graph>.dot -T png -o <figure>.png

项目 CMake 本身的依赖图:

在这里插入图片描述

项目 OpenCV 的依赖图:

dot 布局:

在这里插入图片描述

circo 布局:

在这里插入图片描述

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐