File tree Expand file tree Collapse file tree 5 files changed +58
-10
lines changed
src/main/java/com/aiddroid/java/callgraph Expand file tree Collapse file tree 5 files changed +58
-10
lines changed Original file line number Diff line number Diff line change @@ -4,16 +4,16 @@ A demo app show you how to generate a java call graph.
44### setup
55- import project to netbeans
66- update your own configure in src/main/resources/* .cfg
7- - "Build Project"
7+ - "Build" with dependencies
88
99
1010### run
1111```
12- java -jar java-callgraph- 1.0-SNAPSHOT.jar
12+ java -jar java-call-graph- 1.0-SNAPSHOT-jar-with-dependencies .jar
1313```
1414
1515### call graph
16- - view doT graph below via https://edotor.net/
16+ - View doT graph below via https://edotor.net/
1717```
1818strict digraph G {
1919 com_test_StubImpl_subString_java_lang_String_ [ label="com.test.StubImpl.subString(java.lang.String)" ];
Original file line number Diff line number Diff line change 1616 <plugin >
1717 <groupId >org.apache.maven.plugins</groupId >
1818 <artifactId >maven-jar-plugin</artifactId >
19+ <version >3.2.0</version >
1920 <configuration >
2021 <archive >
2122 <!-- 主配置清单-->
2627 </archive >
2728 </configuration >
2829 </plugin >
30+
31+ <plugin >
32+ <groupId >org.apache.maven.plugins</groupId >
33+ <artifactId >maven-assembly-plugin</artifactId >
34+ <version >3.2.0</version >
35+ <configuration >
36+ <archive >
37+ <manifest >
38+ <mainClass >com.aiddroid.java.callgraph.Application</mainClass >
39+ </manifest >
40+ </archive >
41+ <descriptorRefs >
42+ <descriptorRef >jar-with-dependencies</descriptorRef >
43+ </descriptorRefs >
44+ </configuration >
45+ <executions >
46+ <execution >
47+ <!-- this is used for inheritance merges -->
48+ <id >make-assembly</id >
49+ <!-- 指定在打包节点执行jar包合并操作 -->
50+ <phase >package</phase >
51+ <goals >
52+ <goal >single</goal >
53+ </goals >
54+ </execution >
55+ </executions >
56+ </plugin >
2957 </plugins >
58+
59+ <resources >
60+ <resource >
61+ <directory >src/main/resources</directory >
62+ <includes >
63+ <include >*.cfg</include >
64+ <include >*.xml</include >
65+ </includes >
66+ <excludes >
67+ <exclude >*.png</exclude >
68+ </excludes >
69+ </resource >
70+ </resources >
3071 </build >
3172
3273 <dependencies >
Original file line number Diff line number Diff line change 1- /*
2- * To change this license header, choose License Headers in Project Properties.
3- * To change this template file, choose Tools | Templates
4- * and open the template in the editor.
5- */
61package com .aiddroid .java .callgraph ;
72
83import java .io .StringWriter ;
2015import org .slf4j .LoggerFactory ;
2116
2217/**
23- *
18+ * 应用程序主类
2419 * @author allen
2520 */
2621public class Application {
Original file line number Diff line number Diff line change 1313import java .util .List ;
1414import java .util .stream .Collectors ;
1515
16+ /**
17+ * 符号解析工厂类
18+ * @author allen
19+ */
1620public class SymbolSolverFactory {
1721
1822 private static Logger logger = LoggerFactory .getLogger (SymbolSolverFactory .class );
1923
24+ /**
25+ * 构造方法
26+ * @param srcCfg
27+ * @param libCfg
28+ * @return
29+ */
2030 public static JavaSymbolSolver getJavaSymbolSolverFromConfig (String srcCfg , String libCfg ) {
2131 List <String > srcPaths = Utils .getLinesFrom (srcCfg );
2232 List <String > libPaths = Utils .getLinesFrom (libCfg );
Original file line number Diff line number Diff line change @@ -79,7 +79,9 @@ public static List<String> getLinesFrom(String fileName) {
7979
8080 try {
8181 File file = getFileInResources (fileName );
82- BufferedReader bufferedReader = new BufferedReader (new FileReader (file ));
82+ // BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
83+ InputStream inputStream = Utils .class .getClassLoader ().getResourceAsStream (fileName );
84+ BufferedReader bufferedReader = new BufferedReader (new InputStreamReader (inputStream , "UTF-8" ));
8385 while (null != (line = bufferedReader .readLine ())) {
8486 lines .add (line .trim ());
8587 }
You can’t perform that action at this time.
0 commit comments