I have a project A that use library L v1.0.0 with test scope. Project A also depends on project B (with scope compile), with B transitively depending on the library L v1.0.0 (with scope compile).
Why the final scope of the library L for project A is ‘test’? It causes me NotClassDefFoundError at runtime. It seems that the dependency definition of project A on library L overrides those of the transitive dependencies on L.
What’s wrong here? My project A only uses L for unit tests so I define the dependency with ‘test’ scope. But, at the end, I want L to be on my classpath since project A depends on project B for production, and B needs (transitively) library L.
Thanks for helping me
As an alternative to Peter’s suggestion, just leave L out of the dependencies for A. You should be able to access it anyway, and Maven will treat it as a
compile-scoped dependency.This hides that A’s tests depend on L, though.