How to fix maven dependency scope conflicts (runtime-compile-provided)?

822 views Asked by At

I have a project where I use multiple dependencies. I'm used to execute my code in a dev environment using

mvn compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass="my.Main"

That worked fine until I recently started using a dependency (let's call it A) that defines its own dependencies with the runtime scope. One of its runtime dependencies (let's call it B) is actually a dependency to another dependency of mine that I set with a provided scope (let's call it C).

So I have

MyProject depends on A[compile] who depends on B[runtime]
MyProject depends on C[provided] who depends on B[no-scope-specified]

I end up having B considered as a runtime dependency which results in a ClassNotFoundException when I launch the above command. The only solution I found is adding a dependencyManagement entry that forces its scope to compile.

That bothers me as I do not directly use that dependency (I have no reference to it in my code) so I should not have to bother with it.

Is there some way to avoid that kind of conflict and maybe load all dependencies in the classpath when using mvn exec:java?

Thanks

0

There are 0 answers