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

This is the structure of my multi-module project:

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

In other words, the api module uses slf4j for logging purposes. He does not know what will be the implementation of the logging mechanism. The foo module adds slf4j-log4j12 and slf4j-log4j12 to implement logging. Pretty simple.

Now I run maven-dependency-plugin:analyze-only , and this is what it says for the foo module:

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

The implication is that the plugin does not understand that foo really needs these dependencies. How can i solve the problem?

+8
java maven-2 maven-dependency-plugin
source share
2 answers

What happens if you provide these dependencies a runtime rather than compile ?

If you define them as compile-time dependencies, I think the dependency plugin will think that they are necessary for compilation when they are not really there. But you only need the slf4-log4j and log4j JAR files at runtime.

Edit: You may need to set the ignoreNonCompile parameter:

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

+10
source share

Have you tried slf4j-log4j12 and slf4j-log4j12 at runtime?
See the maven dependency area

0
source share

All Articles