How to tell maven-dependency-plugin that the artifact is used in the project?

血红的双手。 提交于 2019-12-08 16:43:27

问题


This is a structure of my multi-module project:

/root
  /api dependencies: slf4j
  /foo dependencies: slf4j-log4j12, log4j

In other words, module api uses slf4j for logging purposes. It doesn't know what the implementation of logging facility will be. Module foo adds slf4j-log4j12 and log4j in order to implement the logging. Pretty simple.

Now I'm running maven-dependency-plugin:analyze-only and this is what it says for module foo:

[WARNING] Unused declared dependencies found:
[WARNING]    org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[WARNING]    log4j:log4j:jar:1.2.16:compile

Meaning that the plugin doesn't understand that foo really needs these dependencies. How can I solve the problem?


回答1:


What happens if you give those dependencies a runtime scope instead of compile?

If you've defined them as compile-time dependencies I think the dependency plugin will think they are needed for the compile when they're really not. But you only need the slf4-log4j and log4j JAR files at runtime.

Edit: You may need to set the ignoreNonCompile option:

http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html




回答2:


Have you tried setting the scope of slf4j-log4j12 and log4j to runtime?
See maven dependency scope



来源:https://stackoverflow.com/questions/4919297/how-to-tell-maven-dependency-plugin-that-the-artifact-is-used-in-the-project

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