Java 代码解析 mvn dependency tree 结果

com.xxx.xxx:xxx:jar:0.2.4.RELEASE
+- org.projectlombok:lombok:jar:1.16.18:compile
+- org.springframework.cloud:spring-cloud-starter-feign:jar:1.3.5.RELEASE:compile
|  +- org.springframework.cloud:spring-cloud-starter:jar:1.2.4.RELEASE:compile
|  |  +- org.springframework.cloud:spring-cloud-context:jar:1.2.4.RELEASE:compile
|  |  \- org.springframework.security:spring-security-rsa:jar:1.0.3.RELEASE:compile
|  |     \- org.bouncycastle:bcpkix-jdk15on:jar:1.55:compile
|  |        \- org.bouncycastle:bcprov-jdk15on:jar:1.55:compile
|  +- org.springframework.cloud:spring-cloud-netflix-core:jar:1.3.5.RELEASE:compile
|  |  +- org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:compile
|  |  \- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.9.RELEASE:compile
|  +- org.springframework:spring-web:jar:4.3.13.RELEASE:compile
|  |  +- org.springframework:spring-aop:jar:4.3.13.RELEASE:compile
|  |  +- org.springframework:spring-beans:jar:4.3.13.RELEASE:compile
|  |  \- org.springframework:spring-context:jar:4.3.13.RELEASE:compile
|  |     \- org.springframework:spring-expression:jar:4.3.13.RELEASE:compile
|  +- org.springframework.cloud:spring-cloud-commons:jar:1.2.4.RELEASE:compile
|  |  \- org.springframework.security:spring-security-crypto:jar:4.2.3.RELEASE:compile
|  +- io.github.openfeign:feign-core:jar:9.5.0:compile
|  |  \- org.jvnet:animal-sniffer-annotation:jar:1.0:compile
|  +- io.github.openfeign:feign-slf4j:jar:9.5.0:compile
|  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
|  +- io.github.openfeign:feign-hystrix:jar:9.5.0:compile
|  |  +- com.netflix.archaius:archaius-core:jar:0.6.6:compile
|  |  |  \- com.google.code.findbugs:annotations:jar:2.0.0:runtime
|  |  \- com.netflix.hystrix:hystrix-core:jar:1.4.26:compile
|  +- org.springframework.cloud:spring-cloud-starter-ribbon:jar:1.3.5.RELEASE:compile
|  |  +- com.netflix.ribbon:ribbon:jar:2.2.2:compile
|  |  |  +- com.netflix.ribbon:ribbon-transport:jar:2.2.2:runtime
|  |  |  |  +- io.reactivex:rxnetty-contexts:jar:0.4.
...

上面为dependency:tree -DoutputFile=hello -DoutputType=text的结果,如果希望使用Java代码解析上述的信息,可以参考一下内容

<dependency>
    <groupId>org.whitesource</groupId>
    <artifactId>maven-dependency-tree-parser</artifactId>
    <version>1.0.5</version>
</dependency>

Java代码

//file 为 dependency:tree -DoutputFile=hello -DoutputType=text 结果所在的文件(hello为文件名)
FileInputStream fis = new FileInputStream(new File(file))
Reader reader = new BufferedReader(new InputStreamReader(fis));
InputType type = InputType.TEXT;
Parser parser = type.newParser();
Node node = parser.parse(reader);

详情见 https://github.com/adutra/maven-dependency-tree-parser

使用Java代码执行maven命令,可参考文章 https://blog.csdn.net/sweatOtt/article/details/85294488
使用Java代码解析pom.xml内容,可参考文章 https://blog.csdn.net/sweatOtt/article/details/85294408

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值