简体   繁体   中英

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

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM