How does mvn dependency:analyze work?

只谈情不闲聊 提交于 2021-01-28 08:19:45

问题


Can someone let me know how does mvn dependency:analyze work ? An output of mvn dependency:analyze in one of my project shows

[WARNING] Used undeclared dependencies found:
[WARNING]    org.apache.commons:commons-lang3:jar:3.4:compile
[WARNING]    com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
...
[WARNING] Unused declared dependencies found:
[WARNING]    org.springframework.boot:spring-boot-starter-test:jar:1.5.4.RELEASE:test
[WARNING]    org.springframework.restdocs:spring-restdocs-mockmvc:jar:1.1.3.RELEASE:test
[WARNING]    ch.qos.logback:logback-classic:jar:1.1.11:compile

Can some one let me know the following -

  • What does Used undeclared dependencies found denote? Does it mean that this is not declared in pom.xml dependencies but getting used in code and is included via some transitive dependencies?
  • Does Unused declared dependencies found check only for the dependencies declared in pom.xml or it checks transitive dependencies as well?

Maven Version - 3.5.0


回答1:


What does Used undeclared dependencies found denote? Does it mean that this is not declared in pom.xml dependencies but getting used in code and is included via some transitive dependencies?

Exactly!

Does Unused declared dependencies found check only for the dependencies declared in pom.xml or it checks transitive dependencies as well?

Declared dependencies are the dependencies that are declared in your POM. So the plugin does not include transitive dependencies in its check.

Note, that the plugin does a byte-code analysis by default, which is problematic with dependencies that are only used with constants or annotations. This can lead to false reports in some situations. See the FAQ for details.




回答2:


If i remember correctly, maven use the WebASM framework to analyze bytecode and check is lib used or not. Don't trust it, because sometimes maven thinks that lib (dependency) is not used, but it is.



来源:https://stackoverflow.com/questions/48315863/how-does-mvn-dependencyanalyze-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!