My library, call it my-util-lib, uses slf4j as the logging facade. I need a concrete slf4j binding at runtime when I use my library directly, but I don't want the binding jar to be 'inherited' when an application imports my-util-lib. I know I can declare the dependency scope as 'test' in the POM of my-util-lib to accomplish this, but then I cannot run my library directly, other than in JUnit tests. Like if I want to run a main() method from one of my util classes for some quick-n-dirty purpose or quick test. Is there a way to accomplish this? Or to force the scope of a run to 'test' when not running a JUnit test?
Asked
Active
Viewed 1,443 times
1 Answers
2
Set
<scope>provided</scope
on the <dependency>
to slf4j.
For a discussion of the values of scope
, see this question: What's the difference between these Maven dependency scopes: provided/compile/system/
-
That works. But why? From the maven docs: "This scope is only available on the compilation and test classpath, and is not transitive".. It seems it would not be on the normal runtime classpath. – crig May 28 '15 at 13:53
-
-
ok, so I guess when you 'run as java application' in eclipse, it is just using the compilation classpath, so that's why this works. Correct? – crig May 28 '15 at 14:04