开发者

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

开发者 https://www.devze.com 2023-02-08 18:44 出处:网络
This is a structure of my multi-module project: /root /api dependencies: slf4j /foo dependencies: slf4j-log4j12, log4j

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-l开发者_StackOverflow中文版og4j12: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?


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号